Skip to content

sync-request import blocking in worker_threads #134

@cyoyo-geek

Description

@cyoyo-geek

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions