diff options
author | 2023-08-24 14:36:39 -0700 | |
---|---|---|
committer | 2023-08-24 14:36:39 -0700 | |
commit | a051a6f62014b740702594527b19464ce24ba32b (patch) | |
tree | 3556e0e48e46f319595b6d9a3fd05ff40cc74f57 /src/bun.js | |
parent | 9c68abdb8d51951f83b4b253cf5dd3922c2c58b5 (diff) | |
download | bun-a051a6f62014b740702594527b19464ce24ba32b.tar.gz bun-a051a6f62014b740702594527b19464ce24ba32b.tar.zst bun-a051a6f62014b740702594527b19464ce24ba32b.zip |
Fix performance regression in reading from the request body (#4291)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js')
-rw-r--r-- | src/bun.js/api/server.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 445b94617..e96135a5e 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -2876,6 +2876,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp return; } + // This is the start of a task, so it's a good time to drain if (this.request_body != null) { var body = this.request_body.?; @@ -2883,6 +2884,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp if (body.value.Locked.readable) |readable| { if (readable.ptr == .Bytes) { std.debug.assert(this.request_body_buf.items.len == 0); + var vm = this.server.vm; + defer vm.drainMicrotasks(); if (!last) { readable.ptr.Bytes.onData( @@ -2940,8 +2943,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } if (old == .Locked) { - defer this.drainMicrotasks(); - + var vm = this.server.vm; + defer vm.drainMicrotasks(); old.resolve(&body.value, this.server.globalThis); } return; |