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

docs: creating steps, context.error() #18

Merged
merged 7 commits into from
Jan 17, 2024
Merged

docs: creating steps, context.error() #18

merged 7 commits into from
Jan 17, 2024

Conversation

tpluscode
Copy link
Collaborator

No description provided.

Copy link

changeset-bot bot commented Jan 8, 2024

⚠️ No Changeset found

Latest commit: 03bb262

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

github-actions bot commented Jan 8, 2024

Netlify preview deployed to https://18-merge--peppy-toffee-c61eab.netlify.app

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can add one more section covering the related problem of resource cleanup: remember we had to subscribe to events here to ensure finalization code runs also when an exception is thrown by another step

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please, remind me. Did we in the end understand why that event handler was necessary? Why wasn't store.dispose called by the sort function enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

when an exception is thrown by a later step in the pipeline, the async generator is stopped without running its finally block, the event handlers are the only way we could find to ensure finalization code is called. I may try to create a small repro to show the problem and how to address it


1. When using through2, it is not possible to capture a specific `before` stage. Any additional data must be pushed in the `flush` callback.
- Alternatively, a library like [onetime](https://npm.im/onetime) can be used to create `before` stage is only executed once.
2. The stream transform and flush functions are not bound to the context. This means that the context must be captured in a closure, or they must be implemented as arrow functions.
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been tricked by this a few times, glad to see an explanation

Copy link
Contributor

@giacomociti giacomociti left a comment

Choose a reason for hiding this comment

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

nice choice of a working example

@tpluscode tpluscode merged commit db6b9e2 into main Jan 17, 2024
1 check passed
@tpluscode tpluscode deleted the barnard-error branch January 17, 2024 16:05
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.

2 participants