New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 647943 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Service worker can keep itself alive by self postMessage

Project Member Reported by falken@chromium.org, Sep 17 2016

Issue description

Reported here by Hari krishna:
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/XohqW3mcMME/WvEHucgSCgAJ
-------
We have been playing around serviceWorker functionalities. What we did is, we created a message event handler, that spawns another message event for every minute.

Example code shown below.
self.addEventListener('message', function (event) {
    var spawnNewMessageEvent = function (data) {
        return new Promise(function (success) {
            setTimeout(function () {
                var sw = self.registration.active;
                sw.postMessage(data);
                success("success");
            }, 30000)
        });
    };
    event.waitUntil(doSomething().then(spawnNewMessageEvent));
});


 

Comment 2 by mek@chromium.org, Nov 17 2016

Cc: falken@chromium.org
Owner: mek@chromium.org
Status: Started (was: Available)
Project Member

Comment 3 by bugdroid1@chromium.org, Dec 5 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f88b52ec1e4aebd7c1f28b13a58bfad92d04ba94

commit f88b52ec1e4aebd7c1f28b13a58bfad92d04ba94
Author: mek <mek@chromium.org>
Date: Mon Dec 05 20:42:16 2016

Prevent a service worker from keeping itself alive by self postMessage.

This changes the timeout for message events when the message was sent from
a service worker to be the curent timeout of that service worker. So while
a service worker can still post message to itself, this won't allow it to
stay alive any longer than a single event would.

BUG= 647943 , 648836 

Review-Url: https://codereview.chromium.org/2506263005
Cr-Commit-Position: refs/heads/master@{#436393}

[modify] https://crrev.com/f88b52ec1e4aebd7c1f28b13a58bfad92d04ba94/content/browser/service_worker/service_worker_dispatcher_host.cc
[modify] https://crrev.com/f88b52ec1e4aebd7c1f28b13a58bfad92d04ba94/content/browser/service_worker/service_worker_dispatcher_host.h
[modify] https://crrev.com/f88b52ec1e4aebd7c1f28b13a58bfad92d04ba94/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
[modify] https://crrev.com/f88b52ec1e4aebd7c1f28b13a58bfad92d04ba94/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/f88b52ec1e4aebd7c1f28b13a58bfad92d04ba94/content/browser/service_worker/service_worker_version.h

Comment 4 by mek@chromium.org, Dec 13 2016

Labels: M-57
Status: Fixed (was: Started)

Sign in to add a comment