Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(koa): ignore generator-based Koa middleware #1119

Merged

Commits on Aug 22, 2022

  1. 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.
    unflxw committed Aug 22, 2022
    Configuration menu
    Copy the full SHA
    7f66e81 View commit details
    Browse the repository at this point in the history