-
Notifications
You must be signed in to change notification settings - Fork 539
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. Due to the logic in the Koa instrumentation to avoid re-patching middlewares, middlewares are only instrumented the first time they are used. This commit fixes false positives in the test suite due to middleware reuse between tests, and adds a test for the behavior described.
- Loading branch information
Showing
3 changed files
with
119 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters