nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.44k stars 276 forks source link

What happens with process object in Internal realm.js file? #4425

Closed jdiaz-dev closed 6 days ago

jdiaz-dev commented 1 week ago

Node.js Version

v23.0.0-pre

NPM Version

not apply

Operating System

not apply

Subsystem

Other

Description

I am trying to collaborate with node.js internals. I found the realm.js file and I tried to realize a print using process.stdout.write() method but launched an error at moment to compile:

I would like to know why process object is different in realm.js file compared with another normal .js file?

Minimal Reproduction

write process.stdout.write() in any code line in internal realm.js file

Output

TypeError: Cannot read properties of undefined (reading 'write') at internalBinding (node:internal/bootstrap/realm:185:20) at node:internal/bootstrap/realm:191:3

Before You Submit

RedYetiDev commented 6 days ago

These are the files that create the process object. The stdout property hasn't been created yet.

RedYetiDev commented 6 days ago

See the snippet below:

https://github.com/nodejs/node/blob/8e33f20a64fedf234aa6e48a82fdfdb2928a541a/lib/internal/bootstrap/switches/is_main_thread.js#L153

jdiaz-dev commented 5 days ago

What is the alternative to realize a print or a console in this file?

RedYetiDev commented 5 days ago

I'm not sure, sorry