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

sync-request import blocking in worker_threads #134

Open
cyoyo-geek opened this issue Nov 27, 2020 · 0 comments
Open

sync-request import blocking in worker_threads #134

cyoyo-geek opened this issue Nov 27, 2020 · 0 comments

Comments

@cyoyo-geek
Copy link

Run the code multiple times, the program will occasionally get stuck in require().

Operating environment:
node version: v10.16.3
node-worker-threads-pool: 1.4.3
sync-request: 6.1.0


'use strict';
const { StaticPool } = require("node-worker-threads-pool");
async function task(i) {
	require('sync-request'); // Problem code causes the program to occasionally get stuck
	console.log(i);   
	return
}

async function taskStaticPool() {
	const pool = new StaticPool({
		size: 5,
		task: task,
	});

	var execArr = [];
	for (let j = 0; j < 100; j++) {
		execArr.push(pool.exec(j));
	}
	await Promise.all(execArr);
	pool.destroy();
}
taskStaticPool()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant