This commit is contained in:
@@ -120,4 +120,30 @@ redirect_ws_to_real_package() {
|
||||
echo "==> [node_modules] redirecting ws requires past bun's built-in shim"
|
||||
redirect_ws_to_real_package node_modules/mockttp/dist
|
||||
|
||||
# mockttp decides whether a response is still ongoing or already completed by
|
||||
# sniffing the object's shape:
|
||||
#
|
||||
# // Ongoing response has 'getHeaders' - completed has 'headers'.
|
||||
# if ('headers' in response) return response;
|
||||
#
|
||||
# An ongoing response is a live http.ServerResponse; a completed one is the plain
|
||||
# object built by buildInitiatedResponse(). On node that test works, because
|
||||
# ServerResponse has no `headers` property. Bun's ServerResponse *does* have one
|
||||
# (`'headers' in res` === true, typeof object), so the check is inverted for every
|
||||
# single response: waitForCompletedResponse() bails out immediately and hands back
|
||||
# the live ServerResponse, having neither awaited the body nor attached rawHeaders.
|
||||
#
|
||||
# The admin server then tries to serialise that as a GraphQL Response, whose
|
||||
# schema declares `rawHeaders: Json!`, and the whole responseCompleted event is
|
||||
# dropped with "Cannot return null for non-nullable field Response.rawHeaders."
|
||||
# Traffic still proxies correctly - but the UI only ever receives the *initiated*
|
||||
# response, so exchanges render with status and headers and no body, forever.
|
||||
#
|
||||
# Testing for the ongoing-response method instead is unambiguous under either
|
||||
# runtime: a completed response is a plain object and has no getHeaders.
|
||||
echo "==> [node_modules] fixing mockttp's ongoing-vs-completed response check for bun"
|
||||
replace_literal node_modules/mockttp/dist/util/request-utils.js \
|
||||
"if ('headers' in response)" \
|
||||
"if (typeof response.getHeaders !== 'function')"
|
||||
|
||||
echo "==> patch-node-modules.sh complete."
|
||||
|
||||
Reference in New Issue
Block a user