elysiajs / elysia

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

Inconsistent behaviour of `aot` with `noop` handler / empty response #751

Closed bogeychan closed 1 month ago

bogeychan commented 1 month ago

What version of Elysia.JS is running?

1.1.3

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("AOT", () => {
  it.each([
    ["enabled", { aot: true }],
    ["disabled", { aot: false }],
  ])("aot %s should respond without error", async (_name, options) => {
    const app = new Elysia(options).get("/", () => {
      // noop
    });

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

    expect(response.status).toBe(200);
  });
});
bun test

What is the expected behavior?

Both tests pass:

✓ AOT > aot enabled should respond without error
✓ AOT > aot disabled should respond without error

What do you see instead?

aot: false test fails:

✓ AOT > aot enabled should respond without error
11 |       // noop
12 |     });
13 | 
14 |     const response = await app.handle(new Request("http://localhost/"));
15 | 
16 |     expect(response.status).toBe(200);
                                 ^
error: expect(received).toBe(expected)

Expected: 200
Received: 500

✗ AOT > aot disabled should respond without error

Additional information

It fails with status code 500 because of this:

undefined is not an object (evaluating 'M[m]')
SaltyAom commented 1 month ago

Should have been fixed with e946da4, published under 1.1.4

bogeychan commented 1 month ago

ty, works for me