deno icon indicating copy to clipboard operation
deno copied to clipboard

std/node/_events.mjs assumes existence of process, crashes on calling process.emitWarning

Open tkafka opened this issue 1 year ago • 0 comments

Version: Deno 1.43.1

I have a Deno program using mysql2 database pool, and running it crashes on

error: Uncaught TypeError: Cannot read properties of undefined (reading 'emitWarning')
			connection.on('error', function (err) {
			           ^
    at _addListener (ext:deno_node/_events.mjs:471:15)
    at PoolConnection.addListener (ext:deno_node/_events.mjs:485:10)

Here is the file and a call site - it calls process.emitWarning without requiring process anywhere: https://github.com/denoland/deno/blob/main/ext/node/polyfills/_events.mjs#L471

I had to do this in my code to prevent the crash:

// let's add process to global variables, so that _events.mjs is happy being able to call process without declaring it
import process from 'node:process'
window.process = process

I run my deno script with deno run --allow-read --allow-write --allow-net --allow-env ./db-maintenance.ts

(I am not a Deno expert, just a node.js developer trying Deno for scripting some database maintenance)

tkafka avatar May 06 '24 11:05 tkafka