Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait until body file descriptor is open #1054

Merged
merged 3 commits into from Feb 6, 2020

Conversation

szmarczak
Copy link
Collaborator

Fixes #1046

source/create.ts Outdated

options.body.once('error', errorHandler);

// @ts-ignore Each member of the union type '...' has signatures, but none of those signatures are compatible with each other
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it just says that result can be either or a stream or a promise and it doesn't know what types to choose

@szmarczak
Copy link
Collaborator Author

szmarczak commented Feb 6, 2020

Or it could be done via a promise that waits until options.body is readable...

@szmarczak szmarczak changed the title Catch body errors before next tick happens Wait until body file descriptor is open Feb 6, 2020
@szmarczak szmarczak merged commit 453a3a3 into sindresorhus:master Feb 6, 2020
@szmarczak szmarczak deleted the fix-body branch February 6, 2020 22:12
@@ -1,3 +1,4 @@
import {ReadStream} from 'fs';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, it's nicer to rename generic imports like this as it's not immediately clear further down in the code that it's an fs read stream.

import {ReadStream: FsReadStream} from 'fs';

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Body stream error is not caught by Got
2 participants