-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ext/node): only set our end of child process pipe to nonblocking …
…mode (#26495) Fixes playwright on linux, as reported in #16899 (comment). The issue was that we were opening the socket in nonblocking mode, which meant that subprocesses trying to use it would get a `EWOULDBLOCK` error (unexpectedly). The fix here is to only set nonblocking mode on our end (which we need to use asynchronously)
- Loading branch information
1 parent
fa49fd4
commit 7c57105
Showing
4 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
data: hello world | ||
[UNORDERED_START] | ||
child closed | ||
got: hello world | ||
pipe closed | ||
[UNORDERED_END] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 22 additions & 3 deletions
25
tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::os::fd::FromRawFd; | ||
use std::os::unix::net::UnixStream; | ||
|
||
fn main() { | ||
#[cfg(unix)] | ||
{ | ||
let mut stream = unsafe { UnixStream::from_raw_fd(4) }; | ||
let mut pipe = unsafe { File::from_raw_fd(4) }; | ||
|
||
stream.write_all(b"hello world\n").unwrap(); | ||
let mut read = 0; | ||
let mut buf = [0u8; 1024]; | ||
loop { | ||
if read > 4 { | ||
assert_eq!(&buf[..5], b"start"); | ||
break; | ||
} | ||
match pipe.read(&mut buf) { | ||
Ok(n) => { | ||
read += n; | ||
} | ||
Ok(0) => { | ||
return; | ||
} | ||
Err(e) => { | ||
eprintln!("GOT ERROR: {e:?}"); | ||
} | ||
} | ||
} | ||
pipe.write_all(b"hello world").unwrap(); | ||
} | ||
} |