Skip to content

Conversation

@leandrowilliam
Copy link
Contributor

@leandrowilliam leandrowilliam commented Oct 9, 2025

Description

Fixes inflated response times by removing unnecessary multiplication by 1000 in src/registry/middleware/request-handler.ts.

Problem

The response-time library already provides time in milliseconds (as documented here). The code was converting these milliseconds to microseconds by multiplying by 1000 and then parsing as an integer, which:

  • Inflated response time values
  • Reduced precision for fast requests (due to parseInt)
  • Misaligned with standard web performance monitoring practices

Solution

Changed:

duration: Number.parseInt(String(time * 1000), 10),

to

duration: time,

This preserves the original millisecond precision and provides accurate response time reporting.

Screenshots

CleanShot 2025-10-09 at 12 47 39@2x

Testing

  • All existing tests pass (npm test)
  • No breaking changes to the API
  • Response times are now correctly reported in milliseconds

Related Issues

Fixes #1454

Remove unnecessary multiplication by 1000 and parseInt conversion in
request-handler middleware. The response-time library already provides
time in milliseconds, so no conversion is needed.

This fixes inflated response time values and preserves sub-millisecond
precision for accurate performance monitoring.

Fixes opencomponents#1454
@ricardo-devis-agullo
Copy link
Collaborator

makes sense, thanks!

@ricardo-devis-agullo ricardo-devis-agullo merged commit a1e3b7e into opencomponents:master Oct 10, 2025
3 checks passed
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.

Fix inflated response times by removing millisecond-to-microsecond conversion

2 participants