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

Bun – POST request returns 500 status code #4463

Open
raphael-papazikas opened this issue Oct 4, 2023 · 1 comment
Open

Bun – POST request returns 500 status code #4463

raphael-papazikas opened this issue Oct 4, 2023 · 1 comment
Labels
support Questions, discussions, and general support

Comments

@raphael-papazikas
Copy link

raphael-papazikas commented Oct 4, 2023

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: bun 1.x
  • module version with issue: 21.3.x
  • last module version without issue: -
  • environment (e.g. node, browser, native): bun
  • used with (e.g. hapi application, another framework, standalone, ...): hapi application
  • any other relevant information: –

What are you trying to achieve or the steps to reproduce?

Experimenting with bun.

import * as Hapi from '@hapi/hapi';

// this is necessary, because bun does not support this perf_hooks api right now
// <https://github.com/oven-sh/bun/issues/5804>
const PerfHooks = require('perf_hooks');
PerfHooks.performance.eventLoopUtilization = function() {}

const init = async () => {
    const server = Hapi.server({
        port: 4000,
        host: 'localhost'
    });

    server.route({
        path: "/api/test",
        method: "POST",
        handler: function() {
            console.log("successful")
            return {status: "ok"}
        }
    })

    await server.start();
    console.log('Server running on %s', server.info.uri);
};

init();

Steps to reproduce

  • Install bun: https://bun.sh/
  • Install dependencies: bun install --backend=copyfiles
  • Run server bun run index.ts
  • Now you should see Server running on http://localhost:4000
  • Now run a curl request to the recently added endpoint:
curl --request POST \
  --url http://localhost:4000/api/test \
  --header 'Content-Type: application/json' \
  --data '{}'

What was the result you got?

Received 500 status code from the server. Seems like it throws through this line in wreck:
https://github.com/hapijs/wreck/blob/f53808548f8253c194da0f32ac9ae3d986e86d79/lib/index.js#L434 => https://github.com/hapijs/wreck/blob/f53808548f8253c194da0f32ac9ae3d986e86d79/lib/index.js#L429C18-L429C18

What result did you expect?

I would expect the same behavior as for node environment

@raphael-papazikas raphael-papazikas added the support Questions, discussions, and general support label Oct 4, 2023
@damusix
Copy link
Contributor

damusix commented Apr 2, 2024

@raphael-papazikas If a nodejs replica doesn't run Hapi, but Hapi runs in anything Node 16+, then it's not Hapi, it's the nodejs replica. I think the onus is on you guys to find out where the issue lies and report it to the Bun team. You may be solving a critical problem where Bun does not in fact behave like NodeJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

2 participants