question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

self.postMessage is not a function under webpack-dev-server

See original GitHub issue

Do you want to request a feature or report a bug?

Bug

What is the current behavior? screen shot 2017-02-16 at 6 27 48 pm screen shot 2017-02-16 at 6 27 56 pm Self is referring to a wrong object serviceworkerglobalscope instead of window. PostMessage is not defined under serviceworkerglobalscope

If the current behavior is a bug, please provide the steps to reproduce.

Clone https://github.com/didi0613/electrode/tree/webpack-2.0 checkout branch webpack-2.0 npm i && npm run bootstrap goto samples/universal-react-node app npm install gulp dev

What is the expected behavior? There should be no error and pwa should work

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention your webpack and Operating System version. webpack 2.2.0 wepack-dev-server 2.2.0 os: mac

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

103reactions
LeahArmstrongcommented, Nov 1, 2017

Sorry for bringing this thread back to life, but I’ve been dealing with this problem for a few days now on Webpack 3, and think I’ve narrowed it down to at least one possible solution for anyone having problems.

In my Vue project I was submitting Ajax requests from a component. In order to maintain access to update data tied to this further up in my component I used self = this to pass to my function. I missed the var definition in my markup, and Webpack’s self.postMessage was trying to access my Vue data instead.

No errors were presented on compilation since self was already defined as a variable in Webpack.

9reactions
asrofiecommented, Oct 2, 2018

I have same issue, I fixed it with finding self variable and make sure it redefined (using let keyword, e.g let self = this).

Read more comments on GitHub >

github_iconTop Results From Across the Web

self.postMessage is not a function under webpack-dev-server -
self.postMessage is not a function under webpack-dev-server · Do you want to request a feature or report a bug? · What is the...
Read more >
TypeError: e.postMessage is not a function - Stack Overflow
I'm trying to call window.postMesage from my java application for cross-origin communication with qlikview. I am getting below mentioned ...
Read more >
Web Workers | webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Uncaught TypeError: self.importScripts is not a function
在大文件上传的时候,如果在主线程操作,会导致页面卡顿,用户体验不加,就新建一个worker现成,在worker线程里面上传,主线程的交互内容不影响。
Read more >
worker-loader - webpack 3 documentation
If not specified, the same public path used for other webpack assets is used. ... postMessage({ foo: 'foo' }) // Respond to message...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found