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

Tags all messages with IDs #131

Merged
merged 2 commits into from Jun 18, 2019

Conversation

Projects
None yet
2 participants
@paullewis
Copy link
Collaborator

commented Jun 14, 2019

This is a further patch for #126 since it doesn't seem fully resolved. I'm now tagging all outgoing messages to the worker with an ID so we can ensure that the correct callback is executed when the response comes in from the worker. This is on the assumption that worker.onmessage is too brittle for our case, and we have a race condition in terms of which callback is being executed.

paullewis added some commits Jun 14, 2019

@mmocny

mmocny approved these changes Jun 14, 2019

class Detector {
private readonly targets = new Map<number, { id: string }>();
private readonly targets = new Map<number, DetectedImage>();

This comment has been minimized.

Copy link
@mmocny

mmocny Jun 14, 2019

Collaborator

Thanks ;)

});
}

private send(msg: OutgoingWorkerMessage, callback: (data: any) => void) {
const makeRandId = () => {

This comment has been minimized.

Copy link
@mmocny
}

this.workerMessageCallbacks.delete(msgId);
callback.apply(undefined, [data]);

This comment has been minimized.

Copy link
@mmocny

mmocny Jun 14, 2019

Collaborator

suuuper nit, but you can: callback.call(undefined, data) as fyi

@mmocny

This comment has been minimized.

Copy link
Collaborator

commented Jun 14, 2019

Actually Paul, how do you feel about breaking this out into a util? Won't we want something similar for the other workers?

NamedMessagePasser or something like that

@paullewis paullewis merged commit 66f1e08 into master Jun 18, 2019

4 of 5 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
Travis CI - Branch Build Passed
Details
Travis CI - Pull Request Build Passed
Details
cla/google All necessary CLAs are signed
continuous-integration/travis-ci/push The Travis CI build passed
Details

@mmocny mmocny deleted the fix126 branch Jun 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.