Skip to content

fix: bound error-message value serialization - #307

Open
willnie9 wants to merge 1 commit into
vercel:mainfrom
willnie9:fix/bound-error-serialization
Open

willnie9 wants to merge 1 commit into
vercel:mainfrom
willnie9:fix/bound-error-serialization

Conversation

@willnie9

Copy link
Copy Markdown

Closes #306

Summary

  • Replace raw JSON.stringify(...) calls in ms() and parse() error messages (src/index.ts) with a bounded formatErrorValue helper.
  • Summarizes arrays as [Array(length)], non-null objects as [object Type], bigints as ${value}n, and truncates long strings (> 100 chars) so sparse arrays, huge inputs, or bigints never block the event loop or throw a secondary TypeError.
  • Added unit tests in src/index.test.ts verifying bounded error messages and fast failure for large sparse arrays and BigInt arguments.

Verification

  • npm run lint
  • npm run format
  • npm run typecheck
  • npm run test:nodejs (4 suites, 168/168 tests, 100% coverage)
  • npm run test:edge (4 suites, 168/168 tests)

Copilot AI balanced review requested due to automatic review settings November 23, 2026 03:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.

Unbounded error-message serialization in ms() allows a sparse-array argument to block the calling thread

3 participants