Crash if a worker's self.close() method is called within a promise having a catch handler and followed by a new worker created in the main thread

Fixed Issue #7208076

Details

Author
Rotem D.
Created
Apr 14, 2016
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
14.14295
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

This was not very easy to reproduce in a reduced form but eventually I found the trigger.
The problem may actually be more general than the way it’s described here but this seems sufficient to consistently reproduce it.
I have tested it on both Edge 13.10586 and 14.14295 (the version included in latest Windows 10 x64 insider build) and it crashes both.
test.js:

if (typeof window === "object") {
    function startNewWorker() {
        var myWorker = new Worker("test.js");
        myWorker.addEventListener("message", function (event) {
            console.log(event.data);
            
            setTimeout(function() {
                console.log("Starting new worker..");
                var anotherWorker = new Worker("test.js"); // <-- This should trigger the crash
            }, 2000); // <-- It doesn't matter how long is the delay before creating the second worker
        });
        
        myWorker.postMessage("Message to worker");
    }
    
    startNewWorker();
}
else {
    self.addEventListener("message", function() {
        Promise.resolve()
            .then(function() {
                postMessage("Hi from worker!");
                self.close();
            })
            .catch(function () { // <-- The crash only occurs if a 'catch' handler is specified
            });                  // <-- Try removing it and the crash shouldn't happen 
            
    });
}

test.html:

<html>
<head>
    <script src="test.js"></script>
</head>
</html>

Attachments

2 attachments

Comments and activity

  • (There’s no special reason to have the ‘startNewWorker’ function here. This is simply a leftover I forgot to remove from a previous approach.)

  • Microsoft Edge Team

    Changed Assigned To to “Christian F.”

  • Update: it turns out the crash also occurs if the ‘catch’ handler is replaced with a regular ‘then’ handler. It could be the problem is even more general than this.

  • Microsoft Edge Team

    Changed Status to “Fixed”

  • Hello,

    Thank you for the feedback on Edge. Based on my testing here, it looks like this bug was recently fixed and will be resolved to match this.

    In 10586 I was able to see this message shortly after loading the page:

    This page is having a problem loading

    However, when I tested this same exact page in build 14331.1000 – The page never crashes.

    All the best,
    The MS Edge team

You need to sign in to your Microsoft account to add a comment.

Sign in