This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Worker } = require('worker_threads'); | |
const path = require('path'); | |
function runService(workerData) { | |
return new Promise((resolve, reject) => { | |
const worker = new Worker(path.resolve(__dirname, './worker.js'), { workerData }); | |
worker.on('message', resolve); | |
worker.on('error', reject); | |
worker.on('exit', (code) => { | |
if (code !== 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { parentPort } = require('worker_threads'); | |
async function createReq() { | |
const body = { | |
userId: 'test' | |
} | |
const res = await fetch("https://test/track", { | |
"body": JSON.stringify(body), | |
"method": "POST" |