Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

decorate reply with writeEarlyHints #3

Closed
wants to merge 4 commits into from
Closed

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 29, 2022

Checklist

index.js Outdated
if (raw.socket) {
raw.socket.write(serialized, 'utf-8', resolve)
} else {
raw.write(serialized, 'utf-8', resolve)
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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)
Copy link
Member

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.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 29, 2022

closing in favor of #5

@Uzlopak Uzlopak closed this Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants