Repository navigation
Conversation
Chinko21
force-pushed
the
fix/issue-1493-batch-11_20
branch
from
September 28, 2026 07:43
4f0cf94 to
f44b9fc
Compare
Chinko21
force-pushed
the
fix/issue-1493-batch-11_20
branch
from
September 28, 2026 07:45
f44b9fc to
b626ece
Compare
app.ts imported getRequestId from a './lib/request-context.js' module this branch never adds, so `tsc` failed with TS2307 and took every backend job with it. That import (and the X-Request-ID ordering, which belongs to LabsCrypt#1494) is dropped here, and the middleware this PR actually adds is mounted before the routers so BigInt bodies serialize as decimal strings.
Author
|
@LabsCrypt fixed the failing CI on this PR — it is green now. Before: Root cause & fix Head |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Prisma maps
bigintcolumns (streamId,startTime, i128 amounts) to JavaScriptBigInt, whichJSON.stringifycannot encode — it throwsTypeError: Do not know how to serialize a BigInt. The existingBigInt.prototype.toJSONpatch insrc/lib/stream-id.tsonly takes effect when that module happens to be imported by the request path, so it is not a reliable guarantee for every response. This PR adds an explicit serializer plus an Express middleware that routes everyres.json()call — success and error bodies alike — through it.Related Issue
Changes
backend/src/lib/serialize.ts:bigIntSafeReplacerencodesbigintas a decimal string (strings, not numbers, so u64/i128 values aboveNumber.MAX_SAFE_INTEGERkeep full precision),stringifyJsonwrapsJSON.stringify, andbigIntSafeJsonMiddlewarereplacesres.jsonfor the whole app.bigIntSafeJsonMiddlewareinbackend/src/app.tsbefore the routers and the error handler, so no controller or error payload can reach the rawJSON.stringify.backend/tests/serialize.test.tscovering nested objects, nested arrays, plain-value passthrough, independence from the globaltoJSONpatch, and the middleware path via supertest.Verification Results
bigIntSafeJsonMiddlewareoverridesres.jsonfor every response and is mounted inapp.tsbefore the routers, so all controllers share one serializer.Do not know how to serialize a BigInterrorsJSON.stringifysees them;serialize.test.tsdeliberately runs without the globalBigInt.prototype.toJSONpatch and still serializes.tests/serialize.test.tscovers nested objects, nested arrays and top-level BigInts (7 tests passing).Closes #1493