Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Error: Cannot destructure property ok of 'undefined' or 'null'. #5

Open
peecky opened this issue Jan 23, 2020 · 3 comments
Open

Error: Cannot destructure property ok of 'undefined' or 'null'. #5

peecky opened this issue Jan 23, 2020 · 3 comments

Comments

@peecky
Copy link

peecky commented Jan 23, 2020

Hello, I got this error today.

TypeError: Cannot destructure property `ok` of 'undefined' or 'null'.
    at superagentCallback (/node_modules/remote-content/index.js:10:32)
    at Request.callback (/node_modules/remote-content/node_modules/superagent/lib/node/index.js:893:3)
    at ClientRequest.<anonymous> (/node_modules/remote-content/node_modules/superagent/lib/node/index.js:810:12)
    at ClientRequest.emit (events.js:198:13)
    at ClientRequest.EventEmitter.emit (domain.js:448:20)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:198:13)
    at TLSSocket.EventEmitter.emit (domain.js:448:20)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I think when superagentCallback is called by superagentCallback(err) or superagentCallback(err, null), this error would be happen.

@jonkemp
Copy link
Owner

jonkemp commented Jan 23, 2020

Oh, I know what that is. It's due to the conversion to es6 syntax. It can't destructure the property on the response if it doesn't exist. If it's a bigger issue, I'll fix it. Otherwise, I'm planning to move it into a monorepo, which this would be a good issue to test that. So I'll probably wait until then. Perfect first issue for that.

If you need a quick fix before then, you can try fixing the package at 1.1.0 in your repo and see if that resolves the issue.

@peecky
Copy link
Author

peecky commented Jan 24, 2020

My project depends on inline-css. remote-content is indirectly depended on the project. I try to install inline-css version 2.6.x to 2.2.x by npm but each case the npm installs remote-content@1.2.0

$ npm ls remote-content
├─┬ inline-css@2.2.5
│ └─┬ extract-css@1.5.0
│   └─┬ href-content@1.2.0
│     └── remote-content@1.2.0
└── remote-content@1.1.0

It seems that the original error before destructuring is a kind of network error. A simple way of resolving the error is just retrying it. But it can't. The control flow does not come back to my code because it stops inside of superagentCallback. Only the destructuring error can caught by process.on('uncaughtException', ...) with losing the context.

So I wish it could be fixed soon.

@jonkemp
Copy link
Owner

jonkemp commented Jan 25, 2020

v1.2.1 is available.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants