Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(deps): drop node-stream-zip and stoppable (#40398)

Dmitry Gozmana0394b002c91
diff --git a/package-lock.json b/package-lock.json
index a5e442af3f..926d9baf9b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -64,7 +64,6 @@
"@types/react-dom": "^19.2.1",
"@types/retry": "^0.12.5",
"@types/source-map-support": "^0.5.4",
- "@types/stoppable": "^1.1.1",
"@types/ws": "8.2.2",
"@types/xml2js": "^0.4.9",
"@types/yauzl": "^2.10.3",
@@ -105,7 +104,6 @@
"license-checker": "^25.0.1",
"mime": "^3.0.0",
"minimatch": "^3.1.4",
- "node-stream-zip": "^1.15.0",
"open": "8.4.0",
"pngjs": "6.0.0",
"progress": "2.0.3",
@@ -117,7 +115,6 @@
"socks-proxy-agent": "8.0.5",
"source-map-support": "0.5.21",
"ssim.js": "^3.5.0",
- "stoppable": "1.1.0",
"typescript": "^5.9.2",
"vite": "^6.4.1",
"vite-plugin-static-copy": "^3.1.1",
@@ -2778,16 +2775,6 @@
"dev": true,
"license": "MIT"
},
- "node_modules/@types/stoppable": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/@types/stoppable/-/stoppable-1.1.3.tgz",
- "integrity": "sha512-7wGKIBJGE4ZxFjk9NkjAxZMLlIXroETqP1FJCdoSvKmEznwmBxQFmTB1dsCkAvVcNemuSZM5qkkd9HE/NL2JTw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@types/node": "*"
- }
- },
"node_modules/@types/tern": {
"version": "0.23.9",
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.9.tgz",
@@ -7113,19 +7100,6 @@
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz",
"integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw=="
},
- "node_modules/node-stream-zip": {
- "version": "1.15.0",
- "resolved": "https://registry.npmjs.org/node-stream-zip/-/node-stream-zip-1.15.0.tgz",
- "integrity": "sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw==",
- "dev": true,
- "engines": {
- "node": ">=0.12.0"
- },
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/antelle"
- }
- },
"node_modules/nopt": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz",
@@ -8640,17 +8614,6 @@
"node": ">= 0.4"
}
},
- "node_modules/stoppable": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz",
- "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">=4",
- "npm": ">=6"
- }
- },
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
diff --git a/package.json b/package.json
index c123ab5036..9620dea177 100644
--- a/package.json
+++ b/package.json
@@ -106,7 +106,6 @@
"@types/react-dom": "^19.2.1",
"@types/retry": "^0.12.5",
"@types/source-map-support": "^0.5.4",
- "@types/stoppable": "^1.1.1",
"@types/ws": "8.2.2",
"@types/xml2js": "^0.4.9",
"@types/yauzl": "^2.10.3",
@@ -147,7 +146,6 @@
"license-checker": "^25.0.1",
"mime": "^3.0.0",
"minimatch": "^3.1.4",
- "node-stream-zip": "^1.15.0",
"open": "8.4.0",
"pngjs": "6.0.0",
"progress": "2.0.3",
@@ -159,7 +157,6 @@
"socks-proxy-agent": "8.0.5",
"source-map-support": "0.5.21",
"ssim.js": "^3.5.0",
- "stoppable": "1.1.0",
"typescript": "^5.9.2",
"vite": "^6.4.1",
"vite-plugin-static-copy": "^3.1.1",
diff --git a/packages/playwright-core/src/utilsBundle.ts b/packages/playwright-core/src/utilsBundle.ts
index 3d70e0eb1d..af57d4cf10 100644
--- a/packages/playwright-core/src/utilsBundle.ts
+++ b/packages/playwright-core/src/utilsBundle.ts
@@ -71,9 +71,6 @@ export const json5 = json5Library;
import sourceMapSupportLibrary from 'source-map-support';
export const sourceMapSupport = sourceMapSupportLibrary;
-import stoppableLibrary from 'stoppable';
-export const stoppable = stoppableLibrary;
-
import enquirerLibrary from 'enquirer';
export const enquirer = enquirerLibrary;
diff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.ts
index 0228b2e260..19630a30bc 100644
--- a/packages/playwright-ct-core/src/vitePlugin.ts
+++ b/packages/playwright-ct-core/src/vitePlugin.ts
@@ -18,7 +18,7 @@ import fs from 'fs';
import path from 'path';
import { iso, utils, getPlaywrightVersion } from 'playwright-core/lib/coreBundle';
-import { colors, debug, stoppable } from 'playwright-core/lib/utilsBundle';
+import { colors, debug } from 'playwright-core/lib/utilsBundle';
import { cc, transform } from 'playwright/lib/common';
import { removeDirAndLogToConsole } from 'playwright/lib/util';
@@ -37,7 +37,7 @@ import type { ComponentRegistry } from './viteUtils';
const log = debug('pw:vite');
-let stoppableServer: any;
+let previewHttpServer: http.Server | undefined;
const playwrightVersion = getPlaywrightVersion();
export function createPlugin(): TestRunnerPlugin {
@@ -59,7 +59,8 @@ export function createPlugin(): TestRunnerPlugin {
const { viteConfig } = result;
const { preview } = await import('vite');
const previewServer = await preview(viteConfig);
- stoppableServer = stoppable(previewServer.httpServer as http.Server, 0);
+ previewHttpServer = previewServer.httpServer as http.Server;
+ utils.decorateServer(previewHttpServer);
const isAddressInfo = (x: any): x is AddressInfo => x?.address;
const address = previewServer.httpServer.address();
if (isAddressInfo(address)) {
@@ -69,8 +70,8 @@ export function createPlugin(): TestRunnerPlugin {
},
end: async () => {
- if (stoppableServer)
- await new Promise(f => stoppableServer.stop(f));
+ if (previewHttpServer)
+ await new Promise<void>(f => previewHttpServer!.close(() => f()));
},
populateDependencies: async () => {
diff --git a/utils/build/utilsBundleMapping.js b/utils/build/utilsBundleMapping.js
index 64753c7f16..3020a6ea86 100644
--- a/utils/build/utilsBundleMapping.js
+++ b/utils/build/utilsBundleMapping.js
@@ -29,7 +29,6 @@ const MAPPING = {
'yaml': { default: 'yaml' },
'json5': { default: 'json5' },
'source-map-support': { default: 'sourceMapSupport' },
- 'stoppable': { default: 'stoppable' },
'enquirer': { default: 'enquirer' },
'chokidar': { default: 'chokidar' },
'get-east-asian-width': { namespace: 'getEastAsianWidth' },
diff --git a/utils/protocol-types-generator/index.js b/utils/protocol-types-generator/index.js
index 92aa40e350..0219eb8960 100644
--- a/utils/protocol-types-generator/index.js
+++ b/utils/protocol-types-generator/index.js
@@ -1,7 +1,7 @@
// @ts-check
const path = require('path');
const fs = require('fs');
-const StreamZip = require('node-stream-zip');
+const yauzl = require('yauzl');
const vm = require('vm');
const os = require('os');
@@ -128,15 +128,44 @@ function typeOfProperty(property, domain) {
return property.type;
}
+/**
+ * @param {string} zipPath
+ * @param {string} entryName
+ * @returns {Promise<Buffer>}
+ */
+function readFileFromZip(zipPath, entryName) {
+ return new Promise((resolve, reject) => {
+ yauzl.open(zipPath, { lazyEntries: true }, (err, zip) => {
+ if (err) return reject(err);
+ zip.on('entry', entry => {
+ if (entry.fileName !== entryName) {
+ zip.readEntry();
+ return;
+ }
+ zip.openReadStream(entry, (err, readStream) => {
+ if (err) return reject(err);
+ const buffers = [];
+ readStream.on('data', d => buffers.push(d));
+ readStream.on('end', () => {
+ zip.close();
+ resolve(Buffer.concat(buffers));
+ });
+ readStream.on('error', reject);
+ });
+ });
+ zip.on('end', () => reject(new Error(`${entryName} not found in ${zipPath}`)));
+ zip.on('error', reject);
+ zip.readEntry();
+ });
+ });
+}
+
async function generateFirefoxProtocol(executablePath) {
const outputPath = path.join(__dirname, '../../packages/playwright-core/src/server/firefox/protocol.d.ts');
const omnija = os.platform() === 'darwin' ?
path.join(executablePath, '../../Resources/omni.ja') :
path.join(executablePath, '../omni.ja');
- const zip = new StreamZip({file: omnija, storeEntries: true});
- // @ts-ignore
- await new Promise(x => zip.on('ready', x));
- const data = zip.entryDataSync(zip.entry('chrome/juggler/content/protocol/Protocol.js'))
+ const data = await readFileFromZip(omnija, 'chrome/juggler/content/protocol/Protocol.js');
const ctx = vm.createContext();
const protocolJSCode = data.toString('utf8').replace('export const protocol', 'const protocol')