Skip to content

Occasional TimeoutNegativeWarning: -81612681.54468305 is a negative number. #1061

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

Open
peterhirn opened this issue Apr 17, 2025 · 5 comments

Comments

@peterhirn
Copy link

I'm running a Node.js app in K8s. Occasionally (every other day) I get this warning:

(node:1) TimeoutNegativeWarning: -81612681.54468305 is a negative number.
Timeout duration was set to 1.
    at new Timeout (node:internal/timers:195:17)
    at setTimeout (node:timers:138:19)
    at reconnect (file:///app/server/node_modules/postgres/src/connection.js:353:5)
    at Object.connect (file:///app/server/node_modules/postgres/src/connection.js:113:7)
    at connect (file:///app/server/node_modules/postgres/src/index.js:392:7)
    at Query.handler (file:///app/server/node_modules/postgres/src/index.js:336:14)
    at Query.handle (file:///app/server/node_modules/postgres/src/query.js:140:65)

(with varying negative timeout values)

The stacktrace always points to the reconnect function here https://github.com/porsager/postgres/blob/master/src/connection.js#L353

Unfortunately I don't know how to reproduce this issue. On first glance it looks like it happens directly after the app boots up.

@kravetsone
Copy link

kravetsone commented Apr 23, 2025

same issue

DId u know is there any bad thing which happends because of it?

This happened in Bun too

@sep2
Copy link

sep2 commented Jun 2, 2025

We recently update from node 22 to node 24 and from "postgres": "^3.4.5" to "postgres": "^3.4.7" and face the same issue.

@kravetsone
Copy link

I use Bun and got the same issue

But after many times it looks like everything works fine

@peterhirn
Copy link
Author

I don't think there is any negative impact because of this warning, it's just noisy. A simple fix could be

setTimeout(connect, Math.max(closedDate ? closedDate + delay - performance.now() : 0, 0))

@bradley-varol
Copy link

bradley-varol commented Jun 5, 2025

getting this in adonisjs with a postgres db

(node:799128) TimeoutNegativeWarning: -1749131939709 is a negative number.
Timeout duration was set to 1.
(Use `node --trace-warnings ...` to show where the warning was created)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants