elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.64k stars 226 forks source link

Setting header inside `.trace` doesn't work with `aot: false` #837

Open bogeychan opened 2 months ago

bogeychan commented 2 months ago

What version of Elysia is running?

1.1.13

What platform is your computer?

WSL Ubuntu

What steps can reproduce the bug?

// test.test.ts
import { Elysia } from "elysia";
import { describe, it, expect } from "bun:test";

describe("whelp", () => {
  it("yay", async () => {
    const app = new Elysia({ aot: false })
      .trace((set) => {
        set.set.headers["yay"] = "yay";
      })
      .get("/", () => "yay");

    const response = await app.handle(new Request("http://localhost/"));

    expect(response.headers.get("yay")).toEqual("yay");
  });
});

bun test

What is the expected behavior?

test pass

What do you see instead?

test fail:

test.test.ts:
10 |       })
11 |       .get("/", () => "yay");
12 | 
13 |     const response = await app.handle(new Request("http://localhost/"));
14 | 
15 |     expect(response.headers.get("yay")).toEqual("yay");
                                             ^
error: expect(received).toEqual(expected)

Expected: "yay"
Received: null

Additional information

No response

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

yes