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.

Browserify can't be used with `tabs.executeScript`

See original GitHub issue

I get this error in the console:

Error: Script returned non-structured-clonable data

You can test it by browserify-ing an empty file and then using browser.runtime.executeScript to attempt to add it to a page.

Webpack’s module wrapping code doesn’t seem to have this issue.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
BigBlueHatcommented, Apr 24, 2017

@derwaldgeist use two executeScript’s…one for the dependency and one for your applications code that’s formatted in a way to do the return.

Alternatively, you can avoid the who return value thing (which feels very awkward most days…) and use postMessage() and friends.

Oh! and one other possible solution for using a single executeScript the uses require and browserify is to wrap the whole thing in an immediate called function with a return value. Then you get both clarity and lack of cumbersomeness (or…at least less cumbersomeness 😄).

For example…inject.js:

(function() {
  const nifty = require('...');
  return nifty(true);
})();

But then…you may still hit that “structured clonable” thing and have to do some type coercion and such, but at least it’s more obvious than ending your code with a variable name all by its lonesome.

Hope that helps! 🎩

0reactions
wbambergcommented, May 8, 2017

Closing this, as it’s not a bug in the examples in this repo specifically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

chrome.tabs.executeScript with new browser tab not working?
chrome.tabs.executeScript can't be used on newtab page because it instantly fails for the main frame due to unsupported scheme chrome:// and ...
Read more >
tabs.executeScript() - Mozilla - MDN Web Docs
Injects JavaScript code into a page.
Read more >
WebExtensions 101 | Cloudbees Blog
The package.json file is there because I use browserify and npm to manage the dependencies and build the scripts for (most of) my...
Read more >
tabs.executeScript doesn't work with remote files
Is it allowed to pass a remote file URL to tabs.executeScript()? This works: chrome.tabs.executeScript(null, {file: "js/myScript.js"} ); This DOES NOT work:
Read more >
Webextension-polyfill NPM - npm.io
This library allows extensions that use the Promise-based WebExtension/BrowserExt API being ... And for dynamically-injected content scripts loaded by tabs.
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