elysiajs / elysia

Ergonomic Framework for Humans

Home Page:https://elysiajs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bogeychan opened this issue · comments

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]')

Should have been fixed with e946da4, published under 1.1.4

ty, works for me