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

Cannot read properties of undefined (reading 'error') #269

Closed
fredericrous opened this issue Nov 3, 2021 · 1 comment
Closed

Cannot read properties of undefined (reading 'error') #269

fredericrous opened this issue Nov 3, 2021 · 1 comment

Comments

@fredericrous
Copy link
Contributor

The extension I'm working on freezes randomly with the current error message:

Unchecked runtime.lastError: The message port closed before a response was received.
Error handling response: TypeError: Cannot read properties of undefined (reading 'error')
    at chrome-extension://gloenokcpppknddegfmmopacmbfbfdlh/contentScript.bundle.js:48:13164

When I click on the file name, I see the related (minimified) code is

{
                    key: "dispatch",
                    value: function(e) {
                        var t = this;
                        return new Promise((function(n, i) {
                            t.serializedMessageSender(t.extensionId, {
                                type: a.DISPATCH_TYPE,
                                portName: t.portName,
                                payload: e
                            }, null, (function(e) {
                                var t = e.error
                                  , a = e.value;
                                if (t) {
                                    var o = new Error("".concat("\nLooks like there is an error in the background page. You might want to inspect your background page for more details.\n").concat(t));
                                    i((0,
                                    r.default)(o, t))
                                } else
                                    n(a && a.payload)
                            }
                            ))
                        }
                        ))
                    }
                },

It looks like the Issue comes from this line

const {error, value} = resp;

My guess is that we should check if resp is defined and if it is undefined we should check the error coming from runtime.lastError

fredericrous added a commit to fredericrous/webext-redux that referenced this issue Nov 5, 2021
fix random freeze issue "Cannot read properties of undefined (reading 'error')"
tshaddix added a commit that referenced this issue Nov 6, 2021
@tshaddix
Copy link
Owner

tshaddix commented Nov 6, 2021

Fix released in 2.1.8

Thanks for the contribution!

@tshaddix tshaddix closed this as completed Nov 6, 2021
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

No branches or pull requests

2 participants