Skip to content

Commit d9be538

Browse files
authored
fix: response.write() to return a bool (resolves #683) (#702)
Returning 'false'y tells the sender they need to wait for the 'drain' event which can cause middleware to hang (eg. SvelteKit adapter-node and trpc) Original fix from @KATT in KATT@9ba260e
1 parent 916abe7 commit d9be538

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/response.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ module.exports = class ServerlessResponse extends http.ServerResponse {
125125
if (typeof cb === 'function') {
126126
cb()
127127
}
128+
129+
// must return bool to indicate if the data was flushed to the
130+
// kernel and if not then indicate that the sender must wait
131+
// for drain event; which we never do so always return true.
132+
return true;
128133
}
129134
})
130135
}

0 commit comments

Comments
 (0)