Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tkafka opened this issue May 6, 2024 · 0 comments
Labels
bug Something isn't working node compat

Comments

@tkafka
Copy link

tkafka commented May 6, 2024

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)

@marvinhagemeister marvinhagemeister added bug Something isn't working node compat labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node compat
Projects
None yet
Development

No branches or pull requests

2 participants