0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 12:16:11 -05:00

fix(ext/node): do not apply socket-init-workaround to ipc socket (#27779)

This PR resolves 2 issues of Socket class of node compat (both are
related to playwright)

Currently `browser.launch()` of playwright is not working.
`browser.launch` opens PipeTransport (which is based on Pipe/IPC socket)
with the browser process. But that pipe doesn't start reading the data
because of the workaround #27662 (which pauses the socket at the
beginning if it's from playwright-core). This PR fixes this issue by
checking whether the given handle is `ipc` handle or not.

Another issue is that sock-init-workaround for TLS connection stopped
working at #27707 because of the changes of TLS socket initialization
steps. This change fixes the issue by correctly returning the function
in workaround path.

The added case `specs::npm::playwright_compat` checks both fixes with
actual playwright and playwright-core packages.

`browser.launch` issues
closes #16899
closes #27623 

`https.request` issue
closes #27658
This commit is contained in:
Yoshiya Hinosawa 2025-01-28 15:38:45 +09:00 committed by GitHub
parent 3d408e00be
commit 0e47205ebe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 321 additions and 45 deletions

View file

@ -652,6 +652,14 @@ const ci = {
"cache-path": "./target", "cache-path": "./target",
}, },
}, },
{
name: "Set up playwright cache",
uses: "actions/cache@v4",
with: {
path: "./.ms-playwright",
key: "playwright-${{ runner.os }}-${{ runner.arch }}",
},
},
{ {
name: "test_format.js", name: "test_format.js",
if: "matrix.job == 'lint' && matrix.os == 'linux'", if: "matrix.job == 'lint' && matrix.os == 'linux'",

View file

@ -383,6 +383,12 @@ jobs:
uses: ./.github/mtime_cache uses: ./.github/mtime_cache
with: with:
cache-path: ./target cache-path: ./target
- name: Set up playwright cache
uses: actions/cache@v4
with:
path: ./.ms-playwright
key: 'playwright-${{ runner.os }}-${{ runner.arch }}'
if: '!(matrix.skip)'
- name: test_format.js - name: test_format.js
if: '!(matrix.skip) && (matrix.job == ''lint'' && matrix.os == ''linux'')' if: '!(matrix.skip) && (matrix.job == ''lint'' && matrix.os == ''linux'')'
run: deno run --allow-write --allow-read --allow-run --allow-net ./tools/format.js --check run: deno run --allow-write --allow-read --allow-run --allow-net ./tools/format.js --check

5
.gitignore vendored
View file

@ -35,4 +35,7 @@ junit.xml
# Jupyter files # Jupyter files
.ipynb_checkpoints/ .ipynb_checkpoints/
Untitled*.ipynb Untitled*.ipynb
# playwright browser binary cache
/.ms-playwright

View file

@ -1239,7 +1239,7 @@ export class Socket extends Duplex {
super(options); super(options);
// Note: If the socket is created from one of `pkgNeedsSockInitWorkaround`, // Note: If the TCP/TLS socket is created from one of `pkgNeedsSockInitWorkaround`,
// the 'socket' event on ClientRequest object happens after 'connect' event on Socket object. // the 'socket' event on ClientRequest object happens after 'connect' event on Socket object.
// That swaps the sequence of op_node_http_request_with_conn() call and // That swaps the sequence of op_node_http_request_with_conn() call and
// initial socket read. That causes op_node_http_request_with_conn() not // initial socket read. That causes op_node_http_request_with_conn() not
@ -1249,9 +1249,8 @@ export class Socket extends Duplex {
// (and also skips the startTls call if it's TLSSocket) // (and also skips the startTls call if it's TLSSocket)
// TODO(kt3k): Remove this workaround // TODO(kt3k): Remove this workaround
const errorStack = new Error().stack; const errorStack = new Error().stack;
this._needsSockInitWorkaround = pkgsNeedsSockInitWorkaround.some((pkg) => this._needsSockInitWorkaround = options.handle?.ipc !== true &&
errorStack?.includes(pkg) pkgsNeedsSockInitWorkaround.some((pkg) => errorStack?.includes(pkg));
);
if (this._needsSockInitWorkaround) { if (this._needsSockInitWorkaround) {
this.pause(); this.pause();
} }

Binary file not shown.

View file

@ -1,64 +1,109 @@
{ {
"name": "fsevents", "name": "fsevents",
"description": "Native Access to MacOS FSEvents",
"dist-tags": { "dist-tags": {
"latest": "2.3.3" "latest": "2.3.3"
}, },
"versions": { "versions": {
"2.3.3": { "2.3.2": {
"name": "fsevents", "name": "fsevents",
"version": "2.3.3", "version": "2.3.2",
"description": "Native Access to MacOS FSEvents",
"main": "fsevents.js",
"types": "fsevents.d.ts",
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
},
"scripts": {
"clean": "node-gyp clean && rm -f fsevents.node",
"build": "node-gyp clean && rm -f fsevents.node && node-gyp rebuild && node-gyp clean",
"test": "/bin/bash ./test.sh 2>/dev/null",
"prepublishOnly": "npm run build",
"install": "node-gyp rebuild"
},
"repository": {
"type": "git",
"url": "git+https://github.com/fsevents/fsevents.git"
},
"license": "MIT", "license": "MIT",
"_id": "fsevents@2.3.2",
"bugs": { "bugs": {
"url": "https://github.com/fsevents/fsevents/issues" "url": "https://github.com/fsevents/fsevents/issues"
}, },
"devDependencies": { "os": [
"node-gyp": "^9.4.0" "darwin"
}, ],
"gypfile": true, "dist": {
"gitHead": "2db891e51aa0f2975c5eaaf6aa30f13d720a830a", "shasum": "8a526f78b8fdf4623b709e0b975c52c24c02fd1a",
"_id": "fsevents@2.3.3", "tarball": "http://localhost:4260/fsevents/fsevents-2.3.2.tgz",
"_nodeVersion": "18.17.1", "fileCount": 6,
"_npmVersion": "9.6.7", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"unpackedSize": 156422
},
"main": "fsevents.js",
"types": "fsevents.d.ts",
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
},
"gitHead": "a7f5d00939b74e141a73131468c4ce48ee0f2197",
"gypfile": true,
"scripts": {
"test": "/bin/bash ./test.sh 2>/dev/null",
"build": "node-gyp clean && rm -f fsevents.node && node-gyp rebuild && node-gyp clean",
"clean": "node-gyp clean && rm -f fsevents.node",
"install": "node-gyp rebuild",
"prepublishOnly": "npm run build"
},
"repository": {
"url": "git+https://github.com/fsevents/fsevents.git",
"type": "git"
},
"_npmVersion": "6.14.10",
"description": "Native Access to MacOS FSEvents",
"directories": {},
"_nodeVersion": "12.20.1",
"_hasShrinkwrap": false,
"devDependencies": {
"node-gyp": "^6.1.0"
}
},
"2.3.3": {
"name": "fsevents",
"version": "2.3.3",
"license": "MIT",
"_id": "fsevents@2.3.3",
"bugs": {
"url": "https://github.com/fsevents/fsevents/issues"
},
"os": [
"darwin"
],
"dist": { "dist": {
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"shasum": "cac6407785d03675a2a5e1a5305c697b347d90d6", "shasum": "cac6407785d03675a2a5e1a5305c697b347d90d6",
"tarball": "http://localhost:4260/fsevents/fsevents-2.3.3.tgz", "tarball": "http://localhost:4260/fsevents/fsevents-2.3.3.tgz",
"fileCount": 6, "fileCount": 6,
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"unpackedSize": 173224 "unpackedSize": 173224
}, },
"main": "fsevents.js",
"types": "fsevents.d.ts",
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
},
"gitHead": "2db891e51aa0f2975c5eaaf6aa30f13d720a830a",
"gypfile": true,
"scripts": {
"test": "/bin/bash ./test.sh 2>/dev/null",
"build": "node-gyp clean && rm -f fsevents.node && node-gyp rebuild && node-gyp clean",
"clean": "node-gyp clean && rm -f fsevents.node",
"install": "node-gyp rebuild",
"prepublishOnly": "npm run build"
},
"repository": {
"url": "git+https://github.com/fsevents/fsevents.git",
"type": "git"
},
"_npmVersion": "9.6.7",
"description": "Native Access to MacOS FSEvents",
"directories": {}, "directories": {},
"_hasShrinkwrap": false "_nodeVersion": "18.17.1",
"_hasShrinkwrap": false,
"devDependencies": {
"node-gyp": "^9.4.0"
}
} }
}, },
"repository": {
"type": "git",
"url": "git+https://github.com/fsevents/fsevents.git"
},
"readmeFilename": "README.md",
"homepage": "https://github.com/fsevents/fsevents",
"bugs": { "bugs": {
"url": "https://github.com/fsevents/fsevents/issues" "url": "https://github.com/fsevents/fsevents/issues"
}, },
"license": "MIT" "license": "MIT",
"homepage": "https://github.com/fsevents/fsevents",
"repository": {
"url": "git+https://github.com/fsevents/fsevents.git",
"type": "git"
},
"description": "Native Access to MacOS FSEvents",
"readmeFilename": "README.md"
} }

View file

@ -0,0 +1,87 @@
{
"name": "playwright-core",
"dist-tags": {
"latest": "1.49.1"
},
"versions": {
"1.49.1": {
"name": "playwright-core",
"version": "1.49.1",
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"_id": "playwright-core@1.49.1",
"bugs": {
"url": "https://github.com/microsoft/playwright/issues"
},
"bin": {
"playwright-core": "cli.js"
},
"dist": {
"shasum": "32c62f046e950f586ff9e35ed490a424f2248015",
"tarball": "http://localhost:4260/playwright-core/playwright-core-1.49.1.tgz",
"fileCount": 337,
"integrity": "sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==",
"attestations": {
"url": "https://registry.npmjs.org/-/npm/v1/attestations/playwright-core@1.49.1",
"provenance": {
"predicateType": "https://slsa.dev/provenance/v1"
}
},
"unpackedSize": 7966574
},
"types": "types/types.d.ts",
"engines": {
"node": ">=18"
},
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"default": "./index.js",
"require": "./index.js"
},
"./lib/utils": "./lib/utils/index.js",
"./lib/server": "./lib/server/index.js",
"./package.json": "./package.json",
"./lib/zipBundle": "./lib/zipBundle.js",
"./types/structs": "./types/structs.d.ts",
"./types/protocol": "./types/protocol.d.ts",
"./lib/cli/program": "./lib/cli/program.js",
"./lib/utilsBundle": "./lib/utilsBundle.js",
"./lib/outofprocess": "./lib/outofprocess.js",
"./lib/image_tools/stats": "./lib/image_tools/stats.js",
"./lib/image_tools/compare": "./lib/image_tools/compare.js",
"./lib/server/registry/index": "./lib/server/registry/index.js",
"./lib/image_tools/colorUtils": "./lib/image_tools/colorUtils.js",
"./lib/remote/playwrightServer": "./lib/remote/playwrightServer.js",
"./lib/image_tools/imageChannel": "./lib/image_tools/imageChannel.js"
},
"gitHead": "88bc8afc78ea6ff13d2bbb312b99eb924962766c",
"repository": {
"url": "git+https://github.com/microsoft/playwright.git",
"type": "git"
},
"_npmVersion": "10.8.2",
"description": "A high-level API to automate web browsers",
"directories": {},
"_nodeVersion": "18.20.5",
"_hasShrinkwrap": false
}
},
"bugs": {
"url": "https://github.com/microsoft/playwright/issues"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"homepage": "https://playwright.dev",
"repository": {
"url": "git+https://github.com/microsoft/playwright.git",
"type": "git"
},
"description": "A high-level API to automate web browsers",
"readmeFilename": ""
}

Binary file not shown.

View file

@ -0,0 +1,108 @@
{
"name": "playwright",
"dist-tags": {
"latest": "1.49.1"
},
"versions": {
"1.49.1": {
"name": "playwright",
"version": "1.49.1",
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"_id": "playwright@1.49.1",
"bugs": {
"url": "https://github.com/microsoft/playwright/issues"
},
"bin": {
"playwright": "cli.js"
},
"dist": {
"shasum": "830266dbca3008022afa7b4783565db9944ded7c",
"tarball": "http://localhost:4260/playwright/playwright-1.49.1.tgz",
"fileCount": 108,
"integrity": "sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==",
"attestations": {
"url": "https://registry.npmjs.org/-/npm/v1/attestations/playwright@1.49.1",
"provenance": {
"predicateType": "https://slsa.dev/provenance/v1"
}
},
"unpackedSize": 3149816
},
"main": "index.js",
"types": "./index.d.ts",
"engines": {
"node": ">=18"
},
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"default": "./index.js",
"require": "./index.js"
},
"./test": {
"types": "./test.d.ts",
"import": "./test.mjs",
"default": "./test.js",
"require": "./test.js"
},
"./lib/util": "./lib/util.js",
"./types/test": {
"types": "./types/test.d.ts"
},
"./jsx-runtime": {
"import": "./jsx-runtime.mjs",
"default": "./jsx-runtime.js",
"require": "./jsx-runtime.js"
},
"./lib/plugins": "./lib/plugins/index.js",
"./lib/program": "./lib/program.js",
"./package.json": "./package.json",
"./lib/fsWatcher": "./lib/fsWatcher.js",
"./lib/utilsBundle": "./lib/utilsBundle.js",
"./types/testReporter": {
"types": "./types/testReporter.d.ts"
},
"./lib/internalsForTest": "./lib/internalsForTest.js",
"./lib/common/configLoader": "./lib/common/configLoader.js",
"./lib/transform/esmLoader": "./lib/transform/esmLoader.js",
"./lib/transform/transform": "./lib/transform/transform.js",
"./lib/transform/babelBundle": "./lib/transform/babelBundle.js",
"./lib/transform/compilationCache": "./lib/transform/compilationCache.js"
},
"gitHead": "88bc8afc78ea6ff13d2bbb312b99eb924962766c",
"repository": {
"url": "git+https://github.com/microsoft/playwright.git",
"type": "git"
},
"_npmVersion": "10.8.2",
"description": "A high-level API to automate web browsers",
"directories": {},
"_nodeVersion": "18.20.5",
"dependencies": {
"playwright-core": "1.49.1"
},
"_hasShrinkwrap": false,
"optionalDependencies": {
"fsevents": "2.3.2"
}
}
},
"bugs": {
"url": "https://github.com/microsoft/playwright/issues"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"homepage": "https://playwright.dev",
"repository": {
"url": "git+https://github.com/microsoft/playwright.git",
"type": "git"
},
"description": "A high-level API to automate web browsers",
"readmeFilename": ""
}

View file

@ -0,0 +1,16 @@
{
"envs": {
"PLAYWRIGHT_BROWSERS_PATH": "../../../../.ms-playwright"
},
"steps": [{
"args": "run -A npm:playwright install chromium",
"output": "[WILDCARD]"
}, {
// stdio pipes beyond stdin/stdout/stderr are not currently supported on windows
// https://github.com/denoland/deno/issues/23524
// TODO(kt3k): enable this on windows when the issue is fixed
"if": "unix",
"args": "run -A main.ts",
"output": "chromium launched\n"
}]
}

View file

@ -0,0 +1,4 @@
import { chromium } from "npm:playwright";
await chromium.launch();
console.log("chromium launched");
Deno.exit(0);