oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.2k stars 2.77k forks source link

Implement node:http setTimeout #4964

Open pierophp opened 1 year ago

pierophp commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 5.15.90.4-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

I'm trying to use Bun on our service, which uses node:http setTimeout.

Bun is currently throwing a "not implemented" error:

https://github.com/oven-sh/bun/blob/51d3d4382281f789f8175079ed426a63529eb3e7/src/js/node/http.ts#L737C22-L737C37

That is the only issue that I'm having to implement Bun.

Thank you for the great work!

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

jebarpg commented 8 months ago

I just upgraded bun to 1.0.28 and I am now getting this error as well.

stewones commented 8 months ago

same here, we just migrated a big workload to Bun. mysteriously the app seems to be working still.

2024-02-22T16:15:48.154379302Z NotImplementedError: Socket in HTTP setTimeout is not yet implemented in Bun.

2024-02-22T16:15:48.154389422Z code: "ERR_NOT_IMPLEMENTED"

2024-02-22T16:15:48.154425661Z at new NotImplementedError (internal:shared:19:27)

2024-02-22T16:15:48.154512381Z at internal:shared:9:73

2024-02-22T16:15:48.154645461Z at setTimeout (node:http:332:25)

2024-02-22T16:15:48.154659741Z at destroyOnTimeout (/usr/src/app/node_modules/follow-redirects/index.js:199:5)

2024-02-22T16:15:48.154834020Z at startTimer (/usr/src/app/node_modules/follow-redirects/index.js:213:5)

2024-02-22T16:15:48.154847020Z at /usr/src/app/node_modules/follow-redirects/index.js:244:5

2024-02-22T16:15:48.154879860Z at dispatchHttpRequest (/usr/src/app/node_modules/typesense/node_modules/axios/lib/adapters/http.js:360:7)

2024-02-22T16:15:48.154991020Z at new Promise (:1:21)

2024-02-22T16:15:48.155002820Z at httpAdapter (/usr/src/app/node_modules/typesense/node_modules/axios/lib/adapters/http.js:48:10)

2024-02-22T16:15:48.155183539Z at dispatchRequest (/usr/src/app/node_modules/typesense/node_modules/axios/lib/core/dispatchRequest.js:58:10)

2024-02-22T16:15:48.155289539Z at request (/usr/src/app/node_modules/typesense/node_modules/axios/lib/core/Axios.js:108:15)

2024-02-22T16:15:48.155390818Z at wrap (/usr/src/app/node_modules/typesense/node_modules/axios/lib/helpers/bind.js:9:12)

2024-02-22T16:15:48.155448978Z at /usr/src/app/node_modules/typesense/lib/Typesense/ApiCall.js:207:66

2024-02-22T16:15:48.155456138Z at step (/usr/src/app/node_modules/typesense/lib/Typesense/ApiCall.js:33:18)

2024-02-22T16:15:48.155465698Z at /usr/src/app/node_modules/typesense/lib/Typesense/ApiCall.js:14:53

2024-02-22T16:15:48.155692497Z at step (/usr/src/app/node_modules/typesense/lib/Typesense/ApiCall.js:18:137)

2024-02-22T16:15:48.155705577Z at /usr/src/app/node_modules/typesense/lib/Typesense/ApiCall.js:14:53

2024-02-22T16:15:48.155709457Z at /usr/src/app/node_modules/typesense/lib/Typesense/ApiCall.js:8:9

2024-02-22T16:15:48.155740417Z at new Promise (:1:21)
jebarpg commented 8 months ago

Yea the issue only happens when running hot reload for me. I just swapped out bun hot reload for nodemon for now. But my app still runs just fine as well.

jlucaso1 commented 8 months ago

Here is happening on 1.0.29

14 |   warned.add(feature), console.warn(new NotImplementedError(feature, issue));
15 | }, $;
16 | 
17 | class NotImplementedError extends Error {
18 |   code;
19 |   constructor(feature, issue) {
                               ^
NotImplementedError: Server.setTimeout is not yet implemented in Bun.
 code: "ERR_NOT_IMPLEMENTED"

      at new NotImplementedError (internal:shared:19:27)
      at internal:shared:9:73
      at node:http:514:77
      at getServerInstance (/home/user/projects/project/node_modules/@nestjs/platform-fastify/node_modules/fastify/lib/server.js:363:5)
      at createServer (/home/user/projects/project/node_modules/@nestjs/platform-fastify/node_modules/fastify/lib/server.js:25:18)
      at fastify (/home/user/projects/project/node_modules/@nestjs/platform-fastify/node_modules/fastify/fastify.js:197:30)
      at new FastifyAdapter (/home/user/projects/project/node_modules/@nestjs/platform-fastify/adapters/fastify-adapter.js:90:19)
      at /home/user/projects/project/backend/api/test/testHelper.ts:47:7
      at /home/user/projects/project/backend/api/test/meet/meet-livekit.e2e-spec.ts:9:1
shtse8 commented 8 months ago

I have the same issue when running bunx --bun nuxi dev.

You use Bun Node compatibility mode, which is not recommended!
It will affect your performance. Please check our Bun integration recipe, and avoid using 'node:http' for your server implementation.
14 |   warned.add(feature), console.warn(new NotImplementedError(feature, issue));
15 | }, $;
16 | 
17 | class NotImplementedError extends Error {
18 |   code;
19 |   constructor(feature, issue) {
                               ^
NotImplementedError: Socket in HTTP setTimeout is not yet implemented in Bun.
 code: "ERR_NOT_IMPLEMENTED"

      at new NotImplementedError (internal:shared:19:27)
      at internal:shared:9:73
      at setTimeout (node:http:332:25)
      at configureSocket (/home/kyle/anymud/node_modules/@whatwg-node/server/esm/utils.js:217:5)
      at sendNodeResponse (/home/kyle/anymud/node_modules/@whatwg-node/server/esm/utils.js:282:5)
giladv commented 8 months ago

same here. this is a regression for sure

14 |   warned.add(feature), console.warn(new NotImplementedError(feature, issue));
15 | }, $;
16 |
17 | class NotImplementedError extends Error {
18 |   code;
19 |   constructor(feature, issue) {
                               ^
NotImplementedError: Server.setTimeout is not yet implemented in Bun.
 code: "ERR_NOT_IMPLEMENTED"

      at new NotImplementedError (internal:shared:19:27)
      at internal:shared:9:73
      at node:http:514:77
      at getServerInstance (/Volumes/Work/www/crm/node_modules/fastify/lib/server.js:370:5)
      at createServer (/Volumes/Work/www/crm/node_modules/fastify/lib/server.js:25:18)
      at fastify (/Volumes/Work/www/crm/node_modules/fastify/fastify.js:196:30)
      at /Volumes/Work/www/crm/packages/backend/src/index.ts:15:16
Jarred-Sumner commented 8 months ago

This should just be a warning, not an error

Jarred-Sumner commented 8 months ago

but maybe we shouldn't even warn that it is not implemented

MatthewVaccaro commented 8 months ago
NotImplementedError: Socket in HTTP setTimeout is not yet implemented in Bun.
 code: "ERR_NOT_IMPLEMENTED"
  at new NotImplementedError (internal:shared:19:27)
      at internal:shared:9:73
      at setTimeout (node:http:332:25)
      at destroyOnTimeout (/Users/mv/Documents/git/chowscout/waiter/node_modules/follow-redirects/index.js:199:5)
      at startTimer (/Users/mv/Documents/git/chowscout/waiter/node_modules/follow-redirects/index.js:213:5)
      at /Users/mv/Documents/git/chowscout/waiter/node_modules/follow-redirects/index.js:244:5
      at /Users/mv/Documents/git/chowscout/waiter/node_modules/axios/dist/node/axios.cjs:3117:7
      at dispatchHttpRequest (/Users/mv/Documents/git/chowscout/waiter/node_modules/axios/dist/node/axios.cjs:2640:55)
      at /Users/mv/Documents/git/chowscout/waiter/node_modules/axios/dist/node/axios.cjs:2622:5
      at new Promise (:1:21)

I get this when running Puppeteer - I don't have any sockets running or in my project so I am assuming it's due to Puppeteer.

gurachan commented 8 months ago

I have this also only if I build it xD using bun..

tracyloisel commented 8 months ago

same here

mscottnelson commented 8 months ago

Just started trying out bun and ran into this attempting to run a fastify server

jebarpg commented 8 months ago

Just started trying out bun and ran into this attempting to run a fastify server

same

tracyloisel commented 8 months ago

I have used the canary version on dockerfile and it fixed this issue. Fortunately we're not in production

Le ven. 1 mars 2024 à 07:41, Jeb @.***> a écrit :

Just started trying out bun and ran into this attempting to run a fastify server

same

— Reply to this email directly, view it on GitHub https://github.com/oven-sh/bun/issues/4964#issuecomment-1972600871, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAL2LX6ZHW2RNKXOAJJ7ZDYWAPHZAVCNFSM6AAAAAA4TQGGZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSGYYDAOBXGE . You are receiving this because you commented.Message ID: @.***>

kirill-dev-pro commented 8 months ago

bun upgrade --canary fixed it for me, I was on 1.0.29 Waiting for a next stable release

neb-b commented 7 months ago

This is working for me on 1.1.3. I think it can be closed

pierophp commented 7 months ago

It no longer throws an error, but the timeout still doesn't work. Not sure if we should close it.

Electroid commented 7 months ago

setTimeout with node:http is currently a no-op, so we still need to fix this.