Skip to content

fix: Parse x-request-start in seconds, ms, µs, and ns - #124

Merged
adamlogic merged 1 commit into
mainfrom
fix/x-request-start-units
Sep 17, 2026
Merged

adamlogic merged 1 commit into
mainfrom
fix/x-request-start-units

Conversation

@adamlogic

@adamlogic adamlogic commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Summary

queueTimeFromHeaders treated every x-request-start value as whole milliseconds after stripping non-digits. Platforms that send fractional seconds with extra precision (NGINX) or whole nanoseconds (Render) reported 0 or NaN queue time, so queue-time autoscaling silently no-op'd.

This brings the Node parser in line with judoscale-ruby so those header variants produce a real queue time. Fixes #123.

Design decisions

Unit detection uses the same year-2000 magnitude cutoffs as the Ruby adapter, rather than inferring units from digit count or decimal places. That keeps both adapters agreeing on the same header, including t= prefixes and 2–6 decimal fractional seconds.


Note

Medium Risk
Changes queue-time calculation used by Express/Fastify/Next autoscaling metrics; behavior shifts for non-millisecond headers but is intended to fix silent misreporting rather than alter Heroku-ms paths.

Overview
Fixes x-request-start parsing so request queue time is computed correctly across Heroku, NGINX, and Render-style headers instead of often returning 0 or NaN.

queueTimeFromHeaders no longer strips non-digits and assumes milliseconds. It adds startedAtMs, which parses numeric values (including t= prefixes and fractional seconds), infers seconds vs ms/µs/ns using year-2000 magnitude cutoffs aligned with the Ruby adapter, and returns rounded Math.max(0, now - startedAt).

Tests cover NGINX fractional precision (2–6 decimals), microsecond, and nanosecond header values.

Reviewed by Cursor Bugbot for commit d882544. Bugbot is set up for automated code reviews on this repo. Configure here.

Stripping non-digits and assuming milliseconds made Render nanoseconds and extra-precision NGINX timestamps report 0 queue time.
@adamlogic
adamlogic marked this pull request as ready for review September 17, 2026 11:34
@adamlogic
adamlogic merged commit e53715c into main Sep 17, 2026
45 checks passed
@adamlogic
adamlogic deleted the fix/x-request-start-units branch September 17, 2026 11:46
@github-actions github-actions Bot mentioned this pull request Sep 17, 2026
adamlogic pushed a commit that referenced this pull request Sep 17, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>judoscale-bull: 2.1.5</summary>

##
[2.1.5](judoscale-bull-v2.1.4...judoscale-bull-v2.1.5)
(2026-09-17)


### Bug Fixes

* Attach Redis error listeners on Bull and BullMQ collectors
([#121](#121))
([0d682ae](0d682ae))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * judoscale-node-core bumped from 2.5.4 to 2.5.5
</details>

<details><summary>judoscale-bullmq: 2.2.5</summary>

##
[2.2.5](judoscale-bullmq-v2.2.4...judoscale-bullmq-v2.2.5)
(2026-09-17)


### Bug Fixes

* Attach Redis error listeners on Bull and BullMQ collectors
([#121](#121))
([0d682ae](0d682ae))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * judoscale-node-core bumped from 2.5.4 to 2.5.5
</details>

<details><summary>judoscale-express: 2.3.5</summary>

##
[2.3.5](judoscale-express-v2.3.4...judoscale-express-v2.3.5)
(2026-09-17)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * judoscale-node-core bumped from 2.5.4 to 2.5.5
</details>

<details><summary>judoscale-fastify: 2.4.5</summary>

##
[2.4.5](judoscale-fastify-v2.4.4...judoscale-fastify-v2.4.5)
(2026-09-17)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * judoscale-node-core bumped from 2.5.4 to 2.5.5
</details>

<details><summary>judoscale-nextjs: 2.0.2</summary>

##
[2.0.2](judoscale-nextjs-v2.0.1...judoscale-nextjs-v2.0.2)
(2026-09-17)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * judoscale-node-core bumped from 2.5.4 to 2.5.5
</details>

<details><summary>judoscale-node-core: 2.5.5</summary>

##
[2.5.5](judoscale-node-core-v2.5.4...judoscale-node-core-v2.5.5)
(2026-09-17)


### Bug Fixes

* Parse x-request-start in seconds, ms, µs, and ns
([#124](#124))
([e53715c](e53715c))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

queueTimeFromHeaders only handles millisecond x-request-start

1 participant