Skip to content

Commit 2ca97dd

Browse files
jhen0409shellscape
authored andcommitted
Strongly check client isn't running on WebWorker for sendMsg (#929)
1 parent ab889c3 commit 2ca97dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

client/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global __resourceQuery */
1+
/* global __resourceQuery WorkerGlobalScope */
22
var url = require("url");
33
var stripAnsi = require("strip-ansi");
44
var socket = require("./socket");
@@ -47,7 +47,11 @@ function log(level, msg) {
4747

4848
// Send messages to the outside, so plugins can consume it.
4949
function sendMsg(type, data) {
50-
if(typeof self !== "undefined" && self.window) {
50+
if(
51+
typeof self !== "undefined" &&
52+
(typeof WorkerGlobalScope === "undefined" ||
53+
!(self instanceof WorkerGlobalScope))
54+
) {
5155
self.postMessage({
5256
type: "webpack" + type,
5357
data: data

0 commit comments

Comments
 (0)