Chrome extension throwing a “Cannot convert undefined or null to object” error #738
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I try to start Spectron, i got a
javascript error: javascript error: Cannot convert undefined or null to object
in the consoleTo debug this i search lot where can be. I finally found the way to reproduce that error.
Install Debugging tools in VS Code
I install Debugging tests in VS Code tools to help me with this debugging.
Start Debugging
I try to add many break points to find the possible error.
The breakpoint they was the more useful :
fullRequestOptions
I finally found Spectron send Chromedrive debug some functions and the Chromedrive callback. And for this last call back Chromedrive send the
javascript error: Cannot convert undefined or null to object
When you check into this request, you will find the URL use for this request 👍
The URL we got is
http://127.0.0.1:9515/session/{{session_name}}/execute/sync
. Thesession_name
is a random session UIDSo go back to the
fullRequestOptions
and you will see the exact request send to the debug toolAnd next we found these 2 parameters were sent
Try to investigate
I open my Postman application and I try to send POST request with the same parameters.
Bam!!! We have the error
Correct the error
I finally found
electron.remote
not initiated at the point of the code. So I simply add the code to protect this andet voilà
!