Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(koa): ignore generator-based Koa middleware
In Koa 2.x, which is the Koa version currently targeted by the instrumentation, generator-based middleware from Koa 0.x and 1.x are deprecated, and a deprecation warning is shown when these middleware are used. However, most of these middleware still work as intended on Koa version 2.x, due to the use of the `koa-convert` compatibility layer, which is applied automatically when a generator-based middleware is used. Because of this, low-quality tutorial websites continue to recommend the usage of generator-based middleware for error handling. Before this change, using a generator-based middleware alongside the OpenTelemetry instrumentation would break the request, as the instrumentation does not expect a generator-based middleware. Furthermore, the replacement of the middleware with its async-based patch would silence the deprecation warning about the generator-based middleware. After this change, generator-based middleware are not instrumented, and the deprecation warning is shown. Users who wish for their generator-based middleware to be instrumented can manually use `koa-convert`. In Koa 3.x, generator-based middleware will not work, with or without instrumentation.
- Loading branch information