bun icon indicating copy to clipboard operation
bun copied to clipboard

Implement node:http setTimeout

Open pierophp opened this issue 2 years ago • 16 comments

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

pierophp avatar Sep 11 '23 15:09 pierophp

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

jebarpg avatar Feb 21 '24 15:02 jebarpg

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)

stewones avatar Feb 22 '24 21:02 stewones

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.

jebarpg avatar Feb 23 '24 01:02 jebarpg

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

jlucaso1 avatar Feb 23 '24 21:02 jlucaso1

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)

shtse8 avatar Feb 24 '24 10:02 shtse8

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

giladv avatar Feb 25 '24 00:02 giladv

This should just be a warning, not an error

Jarred-Sumner avatar Feb 25 '24 00:02 Jarred-Sumner

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

Jarred-Sumner avatar Feb 25 '24 00:02 Jarred-Sumner

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.

MatthewVaccaro avatar Feb 25 '24 05:02 MatthewVaccaro

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

Succubussix avatar Feb 26 '24 21:02 Succubussix

same here

tracyloisel avatar Feb 28 '24 12:02 tracyloisel

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

mscottnelson avatar Feb 29 '24 15:02 mscottnelson

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

same

jebarpg avatar Mar 01 '24 06:03 jebarpg

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: @.***>

tracyloisel avatar Mar 01 '24 13:03 tracyloisel

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

kirill-dev-pro avatar Mar 01 '24 20:03 kirill-dev-pro

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

neb-b avatar Apr 08 '24 16:04 neb-b

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

pierophp avatar Apr 10 '24 21:04 pierophp

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

Electroid avatar Apr 10 '24 21:04 Electroid