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

Why lie Spawn as Async in docs as it blocks event loops for 1-2 seconds? #55308

Closed
artyres1 opened this issue Oct 7, 2024 · 7 comments
Closed
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. invalid Issues and PRs that are invalid.

Comments

@artyres1
Copy link

artyres1 commented Oct 7, 2024

Version

v20.15.0

Platform

Darwin 0b8642c4-61c5-4802-b52a-d25300ea7210 23.6.0 Darwin Kernel Version 23.6.0: Wed Jul 31 20:49:46 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T8103 arm64

Subsystem

No response

What steps will reproduce the bug?

The following code when ran I notice 1-2 seconds event loop block with execSH which use spawn async version. According to NodeJS docs, spawn shouldn't block event loop unless spawnSync used.

// From https://github.com/tsertkov/exec-sh/blob/master/lib/exec-sh.js
const execSH = require("exec-sh").promise;
const blocked = require('blocked-at')

blocked((time, stack) => {
    console.log(`Event Blocked for ${time}ms, operation started here:`, stack)
  })

async function c(eName, port) {
    await execSH(`avdmanager create avd --name ${eName} --package "system-images;android-34;google_apis;arm64-v8a"`, true);
}

await Promise.all([c("test1", 5412), c("test2", 5413)]);

Please see stacktraces below

` Blocked for 1304.9692919921874ms, operation started here: [
' at AsyncHook.init (/node_modules/blocked-at/index.js:31:11)',
' at emitInitNative (node:internal/async_hooks:202:43)',
' at emitInitScript (node:internal/async_hooks:505:3)',
' at promiseInitHook (node:internal/async_hooks:324:3)',
' at promiseInitHookWithDestroyTracking (node:internal/async_hooks:328:3)',
' at c (testcase.js:10:0)',
' at Module._compile (node:internal/modules/cjs/loader:1358:14)',
' at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)',
' at Module.load (node:internal/modules/cjs/loader:1208:32)',
' at Module._load (node:internal/modules/cjs/loader:1024:12)',
' at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)',
' at node:internal/main/run_main_module:28:49'
]

Blocked for 1472.038375ms, operation started here: [
' at AsyncHook.init (/blocked-at/index.js:31:11)',
' at emitInitNative (node:internal/async_hooks:202:43)',
' at emitInitScript (node:internal/async_hooks:505:3)',
' at promiseInitHook (node:internal/async_hooks:324:3)',
' at promiseInitHookWithDestroyTracking (node:internal/async_hooks:328:3)',
' at c (testcase:10:0)',
' at Module._compile (node:internal/modules/cjs/loader:1358:14)',
' at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)',
' at Module.load (node:internal/modules/cjs/loader:1208:32)',
' at Module._load (node:internal/modules/cjs/loader:1024:12)',
' at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)',
' at node:internal/main/run_main_module:28:49'
]`

How often does it reproduce? Is there a required condition?

..

What is the expected behavior? Why is that the expected behavior?

...

What do you see instead?

..

Additional information

No response

@avivkeller avivkeller closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
@avivkeller avivkeller added wrong repo Issues that should be opened in another repository. invalid Issues and PRs that are invalid. labels Oct 7, 2024
@avivkeller
Copy link
Member

This issue is invalid for a number of reasons:

  1. It relies on a older version of Node.js
  2. It does not fill out the required information
  3. It is about external dependencies.

Please report this to thier maintainers.

@artyres1

This comment was marked as abuse.

@avivkeller
Copy link
Member

The latest LTS isn't 20.15, and exec-sh is an external dependency.

Additionally, you neglected to fill out the issue in the format that has been setup.

If you can reproduce the issue in the latest LTS with child_process (blocked is okay because it's for showing the reproduction), I'll be happy to take another look :-)

@artyres1

This comment was marked as abuse.

@artyres1

This comment was marked as abuse.

@artyres1

This comment was marked as abuse.

@avivkeller avivkeller added duplicate Issues and PRs that are duplicates of other issues or PRs. and removed wrong repo Issues that should be opened in another repository. labels Oct 8, 2024
@avivkeller
Copy link
Member

Regardless of my opinions of the validity of this issue, it's ultimately a duplicate of #14917, and would likely come to the same conclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. invalid Issues and PRs that are invalid.
Projects
None yet
Development

No branches or pull requests

2 participants