Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMException: Failed to execute 'postMessage' on 'Worker': function (a, b, c) { #3

Open
fortil opened this issue Nov 30, 2017 · 2 comments · Fixed by #4
Open

DOMException: Failed to execute 'postMessage' on 'Worker': function (a, b, c) { #3

fortil opened this issue Nov 30, 2017 · 2 comments · Fixed by #4

Comments

@fortil
Copy link

fortil commented Nov 30, 2017

Hi
So thanks by the repo, it's great!!
I can't run the code, it throw me:

DOMException: Failed to execute 'postMessage' on 'Worker': function (a, b, c) {
        if (this instanceof C) {
          switch (arguments.length) {
            case 0:...<omitted>... } could not be cloned.

And my code it's this:

    worker.run(() => {
      if ('indexedDB' in self) {
        return new Promise((resolve, reject) => {
          var openRequest = indexedDB.open('database', 1)
          var db

          openRequest.onsuccess = (event) => {
            db = openRequest.result
            console.log(db)
            getData(db)
          }
          function getData(db) {
            var transaction = db.transaction(['database'], 'readwrite')
            var objectStore = transaction.objectStore('database')

            var objectStoreRequest = objectStore.get('entries')

            objectStoreRequest.onsuccess = function(event) {
              console.log((objectStoreRequest.result))
              resolve(objectStoreRequest.result)
            }
            objectStore.onerror = function(event) {
              reject(transaction.error)
            }
          }
        })
      }
    })
      .then(console.log)
      .catch(console.log)

Any idea?
Thanks

Edit: I have to send 'Promise', cause webpack transform 'Promise'

@fortil fortil changed the title DOMException: Failed to execute 'postMessage' on 'Worker': function get(key) { DOMException: Failed to execute 'postMessage' on 'Worker': function (a, b, c) { Nov 30, 2017
@fortil
Copy link
Author

fortil commented Nov 30, 2017

The error was the Promise, in this case, but now show another error, I removed the polyfills

Code:

Error: Line 34 in blob:http://localhost:9080/ea8378f9-59f9-4efe-a27a-d181c29da420: Uncaught DataCloneError: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': #<Promise> could not be cloned.

But

@fortil
Copy link
Author

fortil commented Nov 30, 2017

I can see that function in run not accept a Promise, but then I don't know how to return the values, 🤔
cause as parameters doesn't i can't pass a function...

@israelss israelss linked a pull request Aug 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant