You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 unknown
What steps can reproduce the bug?
import{Client}from"basic-ftp";import{PassThrough,Readable}from"stream";consthost=" some host here ";constuser=" some user here ";constpass=" some password here ";constfile=" some file here ";constclient=newClient();awaitclient.connect(host);awaitclient.login(user,pass);awaitclient.useDefaultSettings();asyncfunctiontest(){console.time("Finish");constpipe=newPassThrough();constsize=awaitclient.size(file);constreadable=Readable.toWeb(pipe);letread=0;pipe.on("data",(chunk)=>{read+=chunk.length;console.log(".reading:",chunk.length);});pipe.on("end",()=>{console.log("Read:",read);console.timeEnd("Transfer");});console.log("Size:",size);constres=newResponse(readable,{headers: {"Content-Length": size.toString(),},});console.time("Transfer");const[text]=awaitPromise.all([res.text(),client.downloadTo(pipe,file)]);console.log("Final Text:",text.length);console.timeEnd("Finish");}for(leti=0;i<5;i++){console.log(`----- Attempt ${i+1} -----`);awaittest();}client.close();// Bun does not stop after this line while node does.export{};
What is the expected behavior?
should be like running in nodejs (v20.12.2), the reading is complete, no weird long delay, process exit after connection close
$ node --experimental-loader=module test.js
(node:5622) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("module", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
----- Attempt 1 -----
Size: 4146
.reading: 4146
Read: 4146
Transfer: 50.346ms
Final Text: 4146
Finish: 104.405ms
----- Attempt 2 -----
Size: 4146
.reading: 4146
Read: 4146
Transfer: 49.993ms
Final Text: 4146
Finish: 80.264ms
----- Attempt 3 -----
Size: 4146
.reading: 4146
Read: 4146
Transfer: 53.298ms
Final Text: 4146
Finish: 89.71ms
----- Attempt 4 -----
Size: 4146
.reading: 4146
Read: 4146
Transfer: 51.585ms
Final Text: 4146
Finish: 88.152ms
----- Attempt 5 -----
Size: 4146
.reading: 4146
Read: 4146
Transfer: 49.484ms
Final Text: 4146
Finish: 80.072ms
What do you see instead?
$ bun --bun test.js
----- Attempt 1 -----
Size: 4146
.reading: 4146
Read: 4146
[58.89ms] Transfer
Final Text: 4146
[10.48s] Finish
----- Attempt 2 -----
Size: 4146
.reading: 4146
Read: 4146
[47.51ms] Transfer
Final Text: 4146
[10.47s] Finish
----- Attempt 3 -----
Size: 4146
Read: 0
[50.87ms] Transfer
Final Text: 0
[10.47s] Finish
----- Attempt 4 -----
Size: 4146
.reading: 4146
Read: 4146
[60.75ms] Transfer
Final Text: 4146
[10.48s] Finish
----- Attempt 5 -----
Size: 4146
.reading: 4146
Read: 4146
[49.39ms] Transfer
Final Text: 4146
[10.46s] Finish
^C
sometimes read nothing (or only read partially)
weird long delay between transfer finish and task finish
process not stop after connection close (need to Ctrl + C manually)
Additional information
i think there is multiple issues regarding tcp in this issue, mysql2 also seems to not stopping the process after closing the connection.
Windows version of bun is even worse.
Result on windows
Microsoft Windows NT 10.0.22631.0 x64
Bun 1.1.7+b0b7db5c0
> bun --bun test.js
----- Attempt 1 -----
Size: 4146
Read: 0
[70.48ms] Transfer
Final Text: 0
[10.50s] Finish
----- Attempt 2 -----
Size: 4146
Read: 0
[66.35ms] Transfer
Final Text: 0
[10.49s] Finish
----- Attempt 3 -----
Size: 4146
Read: 0
[62.46ms] Transfer
Final Text: 0
[10.49s] Finish
----- Attempt 4 -----
Size: 4146
Read: 0
[54.47ms] Transfer
Final Text: 0
[10.49s] Finish
----- Attempt 5 -----
Size: 4146
Read: 0
[53.33ms] Transfer
Final Text: 0
[10.49s] Finish
Nothing read
The text was updated successfully, but these errors were encountered:
What version of Bun is running?
1.1.7+b0b7db5c0
What platform is your computer?
Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 unknown
What steps can reproduce the bug?
What is the expected behavior?
should be like running in nodejs (v20.12.2), the reading is complete, no weird long delay, process exit after connection close
What do you see instead?
Ctrl + C
manually)Additional information
mysql2
also seems to not stopping the process after closing the connection.Result on windows
Microsoft Windows NT 10.0.22631.0 x64
Bun 1.1.7+b0b7db5c0
Nothing read
The text was updated successfully, but these errors were encountered: