Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Race condition in node #504

Closed
mroz22 opened this issue Dec 4, 2019 · 0 comments
Closed

Race condition in node #504

mroz22 opened this issue Dec 4, 2019 · 0 comments
Labels

Comments

@mroz22
Copy link
Contributor

mroz22 commented Dec 4, 2019

When I run a method with invalid params in node environemnt.

It goes here:

postMessage(new ResponseMessage(responseID, false, { error: ERROR.INVALID_PARAMETERS.message + ': ' + error.message }));

Then core event is emitted and handled here:

case RESPONSE_EVENT :
if (messagePromises[id]) {
// resolve message promise (send result of call method)
messagePromises[id].resolve({
id,
success: message.success,
payload,
});
delete messagePromises[id];
} else {
_log.warn(`Unknown message id ${id}`);
}
break;

As a result, promise is deleted from messagePromises on line 62 above which causes runtime error on line 104:

const postMessage = (message: any, usePromise: boolean = true): ?Promise<void> => {
if (!_core) {
throw new Error('postMessage: _core not found');
}
if (usePromise) {
_messageID++;
message.id = _messageID;
messagePromises[_messageID] = createDeferred();
_core.handleMessage(message, true);
return messagePromises[_messageID].promise;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant