-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
fix(AbortSignal/fetch) fix AbortSignal.timeout, fetch lock behavior and fetch errors #6390
Conversation
c8c8ad6
to
d9f12a2
Compare
struct us_internal_callback_t *internal_cb = (struct us_internal_callback_t *) timer; | ||
|
||
struct kevent64_s event; | ||
EV_SET64(&event, (uint64_t) (void*) internal_cb, EVFILT_TIMER, EV_DELETE, 0, 0, (uint64_t)internal_cb, 0, 0); | ||
kevent64(internal_cb->loop->fd, &event, 1, NULL, 0, 0, NULL); | ||
|
||
/* (regular) sockets are the only polls which are not freed immediately */ | ||
us_poll_free((struct us_poll_t *) timer, internal_cb->loop); | ||
if(fallthrough){ | ||
us_free(timer); |
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.
isn't there a scenario where:
- Timer is scheduled to run in the next tick
- Tick happens, but before timer happens, the timer is cancelled
- Timer is freed
- Callback for timer runs after the timer is freed, which becomes a use-after-free
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.
today we call us_poll_free
with just do:
void us_poll_free(struct us_poll_t *p, struct us_loop_t *loop) {
loop->num_polls--;
us_free(p);
}
so is safe to assume that we are not breaking any behavior only avoiding loop->num_polls--;
because on fallthrough: true
we dont increment num_pools, But will check this scenario.
❌ @cirospaciari 7 files with test failures on bun-darwin-aarch64:
|
❌ @cirospaciari 6 files with test failures on linux-x64-baseline:
|
❌ @cirospaciari 5 files with test failures on linux-x64:
|
❌ @cirospaciari 10 files with test failures on bun-darwin-x64-baseline:
|
What does this PR do?
This fix fetch behavior on error cases, fix HTTP destroying too early causing missing parts/events not to be emitted, fix AbortSignal.timeout, fix proper closing/ending off fetch when aborted, and also fix the state of readable streams to be used not only empty.
Fix #6366
How did you verify your code works?
I wrote automated tests