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

[1.2.15] Nested async plugins mismatch routes to handlers #1075

Closed
goldenstein64 opened this issue Feb 21, 2025 · 0 comments
Closed

[1.2.15] Nested async plugins mismatch routes to handlers #1075

goldenstein64 opened this issue Feb 21, 2025 · 0 comments

Comments

@goldenstein64
Copy link

What version of Elysia is running?

1.2.15

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What steps can reproduce the bug?

Run this test:

import { it, expect } from "bun:test";
import { Elysia } from "elysia";

const asyncPlugin = Promise.resolve(new Elysia({ name: "AsyncPlugin" }));

const plugin = new Elysia({ name: "Plugin" })
  .use(asyncPlugin)
  .get("/plugin", () => "GET /plugin");

const app = new Elysia({ name: "App" })
  .use(plugin)
  .get("/foo", () => "GET /foo")
  .listen(3000);

it("matches the right route", async () => {
  const response = await app.handle(new Request("http://localhost/plugin"));
  const text = await response.text();
  expect(text).toEqual("GET /plugin");
});

What is the expected behavior?

The test should pass.

What do you see instead?

The test fails. expect receives GET /foo instead of GET /plugin.

Additional information

This issue was present in 1.2.14, see #1067. It is still present in 1.2.15.

There is a semi-obvious workaround for this, awaiting the async plugin, but that means any plugins using it will have to be async too if they weren't before. Personally, it's not a deal breaker, but it feels unexpected and is not easy to detect.

I stumbled into this bug while using the @elysiajs/swagger package.

Bun version: 1.2.2+c1708ea6a

Have you try removing the node_modules and bun.lockb and try again yet?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant