Fix a weird race condition where the worker wouldn't be ready when it needed to be
This commit is contained in:
parent
872f67d908
commit
61607dc75d
|
@ -52,12 +52,14 @@ const handleRollWorker = async (rq: QueuedRoll) => {
|
|||
}
|
||||
}, config.limits.workerTimeout);
|
||||
|
||||
rollWorker.addEventListener('message', async (workerMessage) => {
|
||||
if (workerMessage.data === 'ready') {
|
||||
rollWorker.postMessage({
|
||||
rollCmd: rq.rollCmd,
|
||||
modifiers: rq.modifiers,
|
||||
});
|
||||
|
||||
rollWorker.addEventListener('message', async (workerMessage) => {
|
||||
return;
|
||||
}
|
||||
let apiErroredOut = false;
|
||||
try {
|
||||
currentWorkers--;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { parseRoll } from './parser.ts';
|
||||
|
||||
// Alert rollQueue that this worker is ready
|
||||
self.postMessage('ready');
|
||||
|
||||
// Handle the roll
|
||||
self.onmessage = async (e: any) => {
|
||||
const payload = e.data;
|
||||
const returnmsg = parseRoll(payload.rollCmd, payload.modifiers) || {
|
||||
|
|
Loading…
Reference in New Issue