From a9969b7db2c54468167b32cf89385842f0e1fada Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 30 May 2025 00:04:39 -0700 Subject: [PATCH 1/2] Update codex-test-sync.yml --- .github/workflows/codex-test-sync.yml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codex-test-sync.yml b/.github/workflows/codex-test-sync.yml index 8fb57247ed..6da63a1911 100644 --- a/.github/workflows/codex-test-sync.yml +++ b/.github/workflows/codex-test-sync.yml @@ -29,16 +29,27 @@ jobs: with: bun-version: ${{ env.BUN_VERSION }} - - name: Get changed files and sync tests + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 + with: + files: | + test/js/node/test/parallel/**/*.{js,mjs,ts} + test/js/node/test/sequential/**/*.{js,mjs,ts} + + - name: Sync tests + if: steps.changed-files.outputs.any_changed == 'true' shell: bash run: | - # Get the list of changed files from the PR - git diff --name-only origin/main...HEAD | while read -r file; do - if [[ "$file" =~ ^test/js/node/test/(parallel|sequential)/(.+)\.(js|mjs|ts)$ ]]; then - test_name="${BASH_REMATCH[2]}" - echo "Syncing test: $test_name" - bun node:test:cp "$test_name" - fi + echo "Changed test files:" + echo "${{ steps.changed-files.outputs.all_changed_files }}" + + # Process each changed test file + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + # Extract test name from file path + test_name=$(basename "$file" | sed 's/\.[^.]*$//') + echo "Syncing test: $test_name" + bun node:test:cp "$test_name" done - name: Commit changes From fd894f5a656b79ac7b328696efe6cc2b584077bb Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 30 May 2025 00:15:26 -0700 Subject: [PATCH 2/2] Fix test-child-process-server-close (#20062) --- src/js/node/child_process.ts | 2 + .../test-child-process-server-close.js | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/js/node/parallel/test-child-process-server-close.js diff --git a/src/js/node/child_process.ts b/src/js/node/child_process.ts index a0692919c5..7ea8e20ec0 100644 --- a/src/js/node/child_process.ts +++ b/src/js/node/child_process.ts @@ -1498,10 +1498,12 @@ function nodeToBun(item: string, index: number): string | number | null | NodeJS } if (isNodeStreamReadable(item)) { if (Object.hasOwn(item, "fd") && typeof item.fd === "number") return item.fd; + if (item._handle && typeof item._handle.fd === "number") return item._handle.fd; throw new Error(`TODO: stream.Readable stdio @ ${index}`); } if (isNodeStreamWritable(item)) { if (Object.hasOwn(item, "fd") && typeof item.fd === "number") return item.fd; + if (item._handle && typeof item._handle.fd === "number") return item._handle.fd; throw new Error(`TODO: stream.Writable stdio @ ${index}`); } const result = nodeToBunLookup[item]; diff --git a/test/js/node/parallel/test-child-process-server-close.js b/test/js/node/parallel/test-child-process-server-close.js new file mode 100644 index 0000000000..1a88939470 --- /dev/null +++ b/test/js/node/parallel/test-child-process-server-close.js @@ -0,0 +1,38 @@ +const common = require('../common'); +const assert = require('assert'); +const { fork, spawn } = require('child_process'); +const net = require('net'); + +const tmpdir = require('../common/tmpdir'); + +// Run in a child process because the PIPE file descriptor stays open until +// Node.js completes, blocking the tmpdir and preventing cleanup. + +if (process.argv[2] !== 'child') { +// Parent +tmpdir.refresh(); + +// Run test +const child = fork(__filename, ['child'], { stdio: 'inherit' }); +child.on('exit', common.mustCall(function(code) { +assert.strictEqual(code, 0); +})); + +return; +} + +// Child +const server = net.createServer((conn) => { +spawn(process.execPath, ['-v'], { +stdio: ['ignore', conn, 'ignore'] +}).on('close', common.mustCall(() => { +conn.end(); +})); +}).listen(common.PIPE, () => { +const client = net.connect(common.PIPE, common.mustCall()); +client.once('data', () => { +client.end(() => { +server.close(); +}); +}); +});