🎥 Make videos programmatically with React
delete debug statements
Jonny Burgerd4786efaec96
diff --git a/packages/renderer/package.json b/packages/renderer/package.jsonindex 09d62b2c3d..9e1f112ddc 100644--- a/packages/renderer/package.json+++ b/packages/renderer/package.json@@ -20,7 +20,6 @@"url": "https://github.com/remotion-dev/remotion/issues"},"dependencies": {- "debug": "^4.3.4","devtools-protocol": "0.0.1001819","execa": "5.1.1","mime-types": "2.1.35",@@ -40,7 +39,6 @@"@jonny/eslint-config": "3.0.259","@testing-library/dom": "^8.7.2","@testing-library/react": "13.1.1",- "@types/debug": "^4.1.7","@types/jest": "^27.4.0","@types/mime-types": "2.1.1","@types/node": "^16.7.5",diff --git a/packages/renderer/src/browser/BrowserConnector.ts b/packages/renderer/src/browser/BrowserConnector.tsindex c06b50c95f..e8bf7d4dc7 100644--- a/packages/renderer/src/browser/BrowserConnector.ts+++ b/packages/renderer/src/browser/BrowserConnector.ts@@ -20,7 +20,6 @@ import {Connection} from './Connection';import {ConnectionTransport} from './ConnectionTransport';import {NodeWebSocketTransport} from './NodeWebSocketTransport';import {Viewport} from './PuppeteerViewport';-import {debugError} from './util';export interface BrowserConnectOptions {defaultViewport: Viewport;@@ -64,7 +63,7 @@ export async function _connectToBrowser(defaultViewport,process: undefined,closeCallback: () => {- return connection.send('Browser.close').catch(debugError);+ return connection.send('Browser.close').catch(() => undefined);},});}diff --git a/packages/renderer/src/browser/BrowserFetcher.ts b/packages/renderer/src/browser/BrowserFetcher.tsindex 2df68c36a3..8e1780ebda 100644--- a/packages/renderer/src/browser/BrowserFetcher.ts+++ b/packages/renderer/src/browser/BrowserFetcher.ts@@ -27,7 +27,6 @@ import extractZip from 'extract-zip';import * as URL from 'url';import {promisify} from 'util';import {assert} from './assert';-import {debug} from './Debug';import {Product} from './Product';import tar from 'tar-fs';@@ -36,8 +35,6 @@ import {deleteDirectory} from '../delete-directory';const {PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM} = process.env;-const debugFetcher = debug('puppeteer:fetcher');-const downloadURLs: Record<Product, Partial<Record<Platform, string>>> = {chrome: {linux: '%s/chromium-browser-snapshots/Linux_x64/%d/%s.zip',@@ -429,7 +426,7 @@ export class BrowserFetcher {revision);const local = fs.existsSync(folderPath);- debugFetcher({+ console.log({revision,executablePath,folderPath,@@ -475,7 +472,6 @@ function _downloadFile(destinationPath: string,progressCallback: (x: number, y: number) => void): Promise<void> {- debugFetcher(`Downloading binary from ${url}`);let fulfill: (value: void | PromiseLike<void>) => void;let reject: (err: Error) => void;const promise = new Promise<void>((x, y) => {@@ -520,7 +516,6 @@ function _downloadFile(}function install(archivePath: string, folderPath: string): Promise<unknown> {- debugFetcher(`Installing ${archivePath} to ${folderPath}`);if (archivePath.endsWith('.zip')) {return extractZip(archivePath, {dir: folderPath});}@@ -574,7 +569,6 @@ function _installDMG(dmgPath: string, folderPath: string): Promise<void> {}const copyPath = path.join(mountPath as string, appName);- debugFetcher(`Copying ${copyPath} to ${folderPath}`);childProcess.exec(`cp -R "${copyPath}" "${folderPath}"`, (_err) => {if (_err) {reject(_err);@@ -595,7 +589,6 @@ function _installDMG(dmgPath: string, folderPath: string): Promise<void> {}const unmountCommand = `hdiutil detach "${mountPath}" -quiet`;- debugFetcher(`Unmounting ${mountPath}`);childProcess.exec(unmountCommand, (err) => {if (err) {console.error(`Error unmounting dmg: ${err}`);diff --git a/packages/renderer/src/browser/BrowserRunner.ts b/packages/renderer/src/browser/BrowserRunner.tsindex a4856ce77a..fe0c84377c 100644--- a/packages/renderer/src/browser/BrowserRunner.ts+++ b/packages/renderer/src/browser/BrowserRunner.ts@@ -22,14 +22,12 @@ import {promisify} from 'util';import {deleteDirectory} from '../delete-directory';import {assert} from './assert';import {Connection} from './Connection';-import {debug} from './Debug';import {TimeoutError} from './Errors';import {LaunchOptions} from './LaunchOptions';import {NodeWebSocketTransport as WebSocketTransport} from './NodeWebSocketTransport';import {Product} from './Product';import {addEventListener,- debugError,isErrnoException,isErrorLike,PuppeteerEventListener,@@ -39,8 +37,6 @@ import {const renameAsync = promisify(fs.rename);const unlinkAsync = promisify(fs.unlink);-const debugLauncher = debug('puppeteer:launcher');-const PROCESS_ERROR_EXPLANATION = `Puppeteer was unable to kill the process which ran the browser binary.This means that, on future Puppeteer launches, Puppeteer might not be able to launch the browser.Please check your open processes and ensure that the browser processes that Puppeteer launched have been killed.@@ -96,9 +92,6 @@ export class BrowserRunner {}assert(!this.proc, 'This process has previously been started.');- debugLauncher(- `Calling ${this.#executablePath} ${this.#processArguments.join(' ')}`- );this.proc = childProcess.spawn(this.#executablePath,this.#processArguments,@@ -127,7 +120,6 @@ export class BrowserRunner {await deleteDirectory(this.#userDataDir);fulfill();} catch (error) {- debugError(error);reject(error);}} else {@@ -147,7 +139,6 @@ export class BrowserRunner {await renameAsync(prefsBackupPath, prefsPath);}} catch (error) {- debugError(error);reject(error);}}@@ -188,8 +179,7 @@ export class BrowserRunner {this.kill();} else if (this.connection) {// Attempt to close the browser gracefully- this.connection.send('Browser.close').catch((error) => {- debugError(error);+ this.connection.send('Browser.close').catch(() => {this.kill();});}diff --git a/packages/renderer/src/browser/Connection.ts b/packages/renderer/src/browser/Connection.tsindex d54227d27b..17e36f4d8a 100644--- a/packages/renderer/src/browser/Connection.ts+++ b/packages/renderer/src/browser/Connection.ts@@ -14,9 +14,6 @@* limitations under the License.*/import {assert} from './assert';-import {debug} from './Debug';-const debugProtocolSend = debug('puppeteer:protocol:SEND â–º');-const debugProtocolReceive = debug('puppeteer:protocol:RECV â—€');import {Protocol} from 'devtools-protocol';import {ProtocolMapping} from 'devtools-protocol/types/protocol-mapping';@@ -97,13 +94,11 @@ export class Connection extends EventEmitter {_rawSend(message: Record<string, unknown>): number {const id = ++this.#lastId;const stringifiedMessage = JSON.stringify({...message, id});- debugProtocolSend(stringifiedMessage);this.#transport.send(stringifiedMessage);return id;}#onMessage(message: string): void {- debugProtocolReceive(message);const object = JSON.parse(message);if (object.method === 'Target.attachedToTarget') {const {sessionId} = object.params;diff --git a/packages/renderer/src/browser/Debug.ts b/packages/renderer/src/browser/Debug.tsdeleted file mode 100644index e63227d5cf..0000000000--- a/packages/renderer/src/browser/Debug.ts+++ /dev/null@@ -1,93 +0,0 @@-/**- * Copyright 2020 Google Inc. All rights reserved.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import {isNode} from './environment';--declare global {- // eslint-disable-next-line no-var- var __PUPPETEER_DEBUG: string;-}--/**- * A debug function that can be used in any environment.- *- * @remarks- *- * If used in Node, it falls back to the- * {@link https://www.npmjs.com/package/debug | debug module}. In the browser it- * uses `console.log`.- *- * @param prefix - this will be prefixed to each log.- * @returns a function that can be called to log to that debug channel.- *- * In Node, use the `DEBUG` environment variable to control logging:- *- * ```- * DEBUG=* // logs all channels- * DEBUG=foo // logs the `foo` channel- * DEBUG=foo* // logs any channels starting with `foo`- * ```- *- * In the browser, set `window.__PUPPETEER_DEBUG` to a string:- *- * ```- * window.__PUPPETEER_DEBUG='*'; // logs all channels- * window.__PUPPETEER_DEBUG='foo'; // logs the `foo` channel- * window.__PUPPETEER_DEBUG='foo*'; // logs any channels starting with `foo`- * ```- *- * @example- * ```- * const log = debug('Page');- *- * log('new page created')- * // logs "Page: new page created"- * ```- */-export const debug = (prefix: string): ((...args: unknown[]) => void) => {- if (isNode) {- return async (...logArgs: unknown[]) => {- (await import('debug')).default(prefix)(logArgs);- };- }-- return (...logArgs: unknown[]): void => {- const debugLevel = (globalThis as any).__PUPPETEER_DEBUG;- if (!debugLevel) {- return;- }-- const everythingShouldBeLogged = debugLevel === '*';-- const prefixMatchesDebugLevel =- everythingShouldBeLogged ||- /**- * If the debug level is `foo*`, that means we match any prefix that- * starts with `foo`. If the level is `foo`, we match only the prefix- * `foo`.- */- (debugLevel.endsWith('*')- ? prefix.startsWith(debugLevel)- : prefix === debugLevel);-- if (!prefixMatchesDebugLevel) {- return;- }-- // eslint-disable-next-line no-console- console.log(`${prefix}:`, ...logArgs);- };-};diff --git a/packages/renderer/src/browser/FrameManager.ts b/packages/renderer/src/browser/FrameManager.tsindex 38d2e2e774..1f47468351 100644--- a/packages/renderer/src/browser/FrameManager.ts+++ b/packages/renderer/src/browser/FrameManager.ts@@ -33,7 +33,7 @@ import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher';import {NetworkManager} from './NetworkManager';import {Page} from './Page';import {TimeoutSettings} from './TimeoutSettings';-import {debugError, isErrorLike} from './util';+import {isErrorLike} from './util';const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';@@ -415,7 +415,7 @@ export class FrameManager extends EventEmitter {worldName: name,grantUniveralAccess: true,})- .catch(debugError);+ .catch(() => undefined);}));}diff --git a/packages/renderer/src/browser/NetworkManager.ts b/packages/renderer/src/browser/NetworkManager.tsindex 03c1ad6e7f..bcbc0ddea0 100644--- a/packages/renderer/src/browser/NetworkManager.ts+++ b/packages/renderer/src/browser/NetworkManager.ts@@ -22,7 +22,7 @@ import {Frame} from './FrameManager';import {HTTPRequest} from './HTTPRequest';import {HTTPResponse} from './HTTPResponse';import {FetchRequestId, NetworkEventManager} from './NetworkEventManager';-import {debugError, isString} from './util';+import {isString} from './util';export const NetworkManagerEmittedEvents = {Request: Symbol('NetworkManager.Request'),@@ -125,7 +125,7 @@ export class NetworkManager extends EventEmitter {requestId: event.requestId,authChallengeResponse: {response, username, password},})- .catch(debugError);+ .catch(() => undefined);}/**@@ -271,7 +271,7 @@ export class NetworkManager extends EventEmitter {responseReceived.requestId);if (extraInfos.length) {- debugError(+ console.log(new Error('Unexpected extraInfo events for request ' +responseReceived.requestIddiff --git a/packages/renderer/src/browser/Page.ts b/packages/renderer/src/browser/Page.tsindex 0dc8c05c91..25f8d9eaf7 100644--- a/packages/renderer/src/browser/Page.ts+++ b/packages/renderer/src/browser/Page.ts@@ -14,6 +14,7 @@* limitations under the License.*/+import {error} from 'console';import {Protocol} from 'devtools-protocol';import {assert} from './assert';import {CDPSession} from './Connection';@@ -36,7 +37,6 @@ import {Target} from './Target';import {TaskQueue} from './TaskQueue';import {TimeoutSettings} from './TimeoutSettings';import {- debugError,evaluationString,isErrorLike,pageBindingDeliverErrorString,@@ -110,7 +110,7 @@ export class Page extends EventEmitter {.send('Target.detachFromTarget', {sessionId: event.sessionId,})- .catch(debugError);+ .catch(() => console.log(error));}});@@ -269,25 +269,23 @@ export class Page extends EventEmitter {assert(pageBinding);const result = await pageBinding(...args);expression = pageBindingDeliverResultString(name, seq, result);- } catch (error) {- if (isErrorLike(error)) {+ } catch (_error) {+ if (isErrorLike(_error)) {expression = pageBindingDeliverErrorString(name,seq,- error.message,- error.stack+ _error.message,+ _error.stack);} else {- expression = pageBindingDeliverErrorValueString(name, seq, error);+ expression = pageBindingDeliverErrorValueString(name, seq, _error);}}- this.#client- .send('Runtime.evaluate', {- expression,- contextId: event.executionContextId,- })- .catch(debugError);+ this.#client.send('Runtime.evaluate', {+ expression,+ contextId: event.executionContextId,+ });}#addConsoleMessage(diff --git a/packages/renderer/src/browser/util.ts b/packages/renderer/src/browser/util.tsindex b608202c53..a59daf2358 100644--- a/packages/renderer/src/browser/util.ts+++ b/packages/renderer/src/browser/util.ts@@ -17,12 +17,9 @@import {Protocol} from 'devtools-protocol';import {assert} from './assert';import {CDPSession} from './Connection';-import {debug} from './Debug';import {TimeoutError} from './Errors';import {CommonEventEmitter} from './EventEmitter';-export const debugError = debug('puppeteer:error');-export function getExceptionMessage(exceptionDetails: Protocol.Runtime.ExceptionDetails): string {@@ -88,10 +85,9 @@ export async function releaseObject(await client.send('Runtime.releaseObject', {objectId: remoteObject.objectId})- .catch((error) => {+ .catch(() => {// Exceptions might happen in case of a page been navigated or closed.// Swallow these since they are harmless and we don't leak anything in this case.- debugError(error);});}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 1c26f02529..45f511109f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -703,7 +703,6 @@ importers:'@jonny/eslint-config': 3.0.259'@testing-library/dom': ^8.7.2'@testing-library/react': 13.1.1- '@types/debug': ^4.1.7'@types/jest': ^27.4.0'@types/mime-types': 2.1.1'@types/node': ^16.7.5@@ -713,7 +712,6 @@ importers:'@types/tar-fs': 2.0.1'@types/unbzip2-stream': 1.4.0'@types/ws': 8.5.3- debug: ^4.3.4devtools-protocol: 0.0.1001819eslint: 8.13.0execa: 5.1.1@@ -734,7 +732,6 @@ importers:unbzip2-stream: 1.4.3ws: 8.7.0dependencies:- debug: 4.3.4devtools-protocol: 0.0.1001819execa: 5.1.1extract-zip: 2.0.1@@ -749,7 +746,6 @@ importers:'@jonny/eslint-config': 3.0.259_6hvhxfirl4y3p6nuemvvvbadcu'@testing-library/dom': 8.7.2'@testing-library/react': 13.1.1_zpnidt7m3osuk7shl3s4oenomq- '@types/debug': 4.1.7'@types/jest': 27.4.0'@types/mime-types': 2.1.1'@types/node': 16.10.2@@ -7650,12 +7646,6 @@ packages:'@types/node': 16.10.2dev: false- /@types/debug/4.1.7:- resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==}- dependencies:- '@types/ms': 0.7.31- dev: true-/@types/eslint-scope/3.7.3:resolution: {integrity: sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g==}dependencies:@@ -7783,10 +7773,6 @@ packages:'@types/node': 17.0.17dev: true- /@types/ms/0.7.31:- resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==}- dev: true-/@types/node/12.20.27:resolution: {integrity: sha512-qZdePUDSLAZRXXV234bLBEUM0nAQjoxbcSwp1rqSMUe1rZ47mwU6OjciR/JvF1Oo8mc0ys6GE0ks0HGgqAZoGg==}dev: false