Override `highWaterMark` didn't work
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- node.js, typescript
- Domain
- backend
Research direction
Start at the awslambda.streamifyResponse entry point and trace how its highWaterMark option and handler symbol are consumed. Reproduce the two examples and verify that a configured value of 512 delivers the early writes before the delayed writes.
Written by the indexing model from the issue text.
Description
The following code will send the data BEFORE 6s:
const util = require('node:util');
const HANDLER_HIGHWATERMARK = Symbol.for(
'aws.lambda.runtime.handler.streaming.highWaterMark',
);
const handler = async (event, responseStream, context) => {
responseStream.setContentType('text/html; charset=utf-8');
responseStream.write("Thinking...");
responseStream.write("a".repeat(64 * 1024));
setTimeout(function() {
responseStream.write("b".repeat(64 * 1024));
}, 3000);
setTimeout(function() {
responseStream.write("After 6s");
responseStream.end();
}, 6000);
};
handler[HANDLER_HIGHWATERMARK] = 512;
exports.handler = awslambda.streamifyResponse(handler, {
highWaterMark: 512
}
);
The following code will only send data AFTER 6s.
const util = require('node:util');
const HANDLER_HIGHWATERMARK = Symbol.for(
'aws.lambda.runtime.handler.streaming.highWaterMark',
);
const handler = async (event, responseStream, context) => {
responseStream.setContentType('text/html; charset=utf-8');
responseStream.write("Thinking...");
responseStream.write("a".repeat(1 * 1024));
setTimeout(function() {
responseStream.write("b".repeat(1 * 1024));
}, 3000);
setTimeout(function() {
responseStream.write("After 6s");
responseStream.end();
}, 6000);
};
handler[HANDLER_HIGHWATERMARK] = 512;
exports.handler = awslambda.streamifyResponse(handler, {
highWaterMark: 512
}
);
From what I tested, the default highWaterMark is 64Kb, but there is no way to override it to be lower, I tried two different ways to do it.
This causes weird issues where I can't send some tiny text and then wait 6s to send more data, it will be sent as a single chunk only after 6s.
This issue was initially discovered at https://github.com/H4ad/serverless-adapter/issues/166
- Dominant language
- TypeScript
- Stars
- 224
- Forks
- 60
- Avg merge
- 26m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/aws-lambda-nodejs-runtime-interface-client
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
aws/aws-lambda-nodejs-runtime-interface-client#198 · 3 comments · 6 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
aws/aws-lambda-nodejs-runtime-interface-client#195 · 12 reactions ·
-
bug
aws/aws-lambda-nodejs-runtime-interface-client#170 · 15 comments · 6 reactions · 1 assignee ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
aws/aws-lambda-nodejs-runtime-interface-client#159 · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
aws/aws-lambda-nodejs-runtime-interface-client#145 · 1 comment · 6 reactions ·
All issues in aws/aws-lambda-nodejs-runtime-interface-client
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ontola/atomic-server#1625 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
melgarafael/DeskcommCRM#1451 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
bug via-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bot:ai-assisted component:compact-js status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
midnightntwrk/midnight-sdk#403 ·