-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
index.js
Outdated
if (raw.socket) { | ||
raw.socket.write(serialized, 'utf-8', resolve) | ||
} else { | ||
raw.write(serialized, 'utf-8', resolve) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the else needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
socket can be null. In that case we use raw.write.
I would actually also prefer to know why socket is null sometimes. Any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If socket
is null we should not be writing early hints at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If socket is null it means there is no actual socket behind the request, i.e. the request was aborted.
index.js
Outdated
const serialized = serialize(earlyHints) | ||
return new Promise(resolve => { | ||
if (raw.socket) { | ||
raw.socket.write(serialized, 'utf-8', resolve) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that the callback of write()
could have an err
as the first argument, which unfortunately means we should reject the promise.
closing in favor of #5 |
Checklist
npm run test
andnpm run benchmark
and the Code of conduct