meteor / meteor

Meteor, the JavaScript App Platform
https://meteor.com
Other
44.31k stars 5.17k forks source link

Object.keys(null) possible - cannot convert undefined or null to object #12079

Closed loliarz closed 1 year ago

loliarz commented 2 years ago

https://github.com/meteor/meteor/blob/9530de1ac97f7736bfa7caeffda6a756603919fd/packages/ddp-client/common/livedata_connection.js#L1626

Conditions above this line allow msg===null to get into Object.keys(msg);

livedata_connection.js:1626 Uncaught TypeError: Cannot convert undefined or null to objectat Function.keys (<anonymous>)at Connection.onMessage (livedata_connection.js:1626:20)at browser.js:184:11at Array.forEach (<anonymous>)at ClientStream.forEachCallback (common.js:30:31)at SockJS.socket.onmessage (browser.js:183:14)at SockJS.REventTarget.dispatchEvent (sockjs-0.3.4.js:87:22)at SockJS._dispatchMessage (sockjs-0.3.4.js:1078:10)at SockJS._didMessage (sockjs-0.3.4.js:1138:18)at WebSocket.that.ws.onmessage (sockjs-0.3.4.js:1285:17)

denihs commented 2 years ago

That's a weird if statement...

Are you able to provide a reproduction or tell the specific scenario where you were able to catch this error?

It would make it easier to test a solution later.

barisunsalhn commented 2 years ago

Could you assign me?

Grubba27 commented 2 years ago

Sure! @lapaz17 is free to be taken, if you need any help solving this issue you can reach out here on this issue or you can create a draft Pull Request so that we can help you there as well

barisunsalhn commented 2 years ago

@Grubba27 Do you think if (( msg && Object.keys(msg).length === 1) && msg.server_id) is enough solution?

Grubba27 commented 2 years ago

Hey @lapaz17, I think it would work if given a reproduction of a test scenario for this. I would add tests in packages/ddp-client/test/livedata_connection_tests.js

harshit-dugar commented 1 year ago

If this issue is not resolved shall I do this?

radekmie commented 1 year ago

@harshit-dugar If you're able to reproduce it, then sure.

rohit1kumar commented 1 year ago

https://github.com/meteor/meteor/blob/9530de1ac97f7736bfa7caeffda6a756603919fd/packages/ddp-client/common/livedata_connection.js#L1626

Conditions above this line allow msg===null to get into Object.keys(msg);

livedata_connection.js:1626 Uncaught TypeError: Cannot convert undefined or null to objectat Function.keys (<anonymous>)at Connection.onMessage (livedata_connection.js:1626:20)at browser.js:184:11at Array.forEach (<anonymous>)at ClientStream.forEachCallback (common.js:30:31)at SockJS.socket.onmessage (browser.js:183:14)at SockJS.REventTarget.dispatchEvent (sockjs-0.3.4.js:87:22)at SockJS._dispatchMessage (sockjs-0.3.4.js:1078:10)at SockJS._didMessage (sockjs-0.3.4.js:1138:18)at WebSocket.that.ws.onmessage (sockjs-0.3.4.js:1285:17)

How to reproduce this ?

Im-Madhur-Gupta commented 1 year ago

@radekmie @Grubba27 Hey guys, I have created a draft PR for this issue, I am having some trouble in writing tests for the same, and need some help.

I think the test will go inside the onConnected() function present in the packages/ddp-client/test/livedata_connection_tests.js file, not sure about it, can you please guide me a little on where to add the test?

image

PS: This is my first open-source contribution.

radekmie commented 1 year ago

I don't know exactly and won't have time to look into it soon, sorry. (Mostly because this no longer seems urgent, as there's no reproduction nor more reports of this.)

Im-Madhur-Gupta commented 1 year ago

Alright. no problem.

nhtbao101 commented 1 year ago

Hello guys, I have a trouble with this problem.

image

I am working on this branch and this error was showed. But some friend when working also on this branch, this error NOT showing. I don't know why. Could you help me?. Thank you so much!!

radekmie commented 1 year ago

@nhtbao101 I'm pretty sure it's completely unrelated - this issue is about some server code, and you see an error in the browser. It's just "the same error"; someone did Object.keys on undefined or null. Check your companion-bubble.js file.

bsartain commented 1 year ago

One possible solution is from this post https://stackoverflow.com/questions/74281137/companion-bubble-js-in-the-console.

Looks like the Chrome Extension for Loom causes the error.

fitz95 commented 1 year ago

just saw someone say it's the loom extension causing this issue

MWarrior715 commented 1 year ago

In my case I disabled loom and it effectively solved the problem

nuruzzamannirob commented 1 year ago

just saw someone say it's the loom extension causing this issue

Thank you

lfgalang commented 1 year ago

Yeah, I also dissabled the loom extension and the problem was solved. Thanks

davidsavoie1 commented 1 year ago

Wow! I've been debugging this error for two hours now, scratching my head and disabling everything I could to pinpoint the issue... and it seems to be caused by the Meteor DevTools Evolved 1.8 Chrome extension! It occurred when publishing a cursor with a nested object of shape { location: { coordinates: [...values] } } if any value in the array was null.

I didn't get the error:

I'll file an issue at the extension's GitHub page. I seee the 1.8 version has been released three days ago. This was very confusing, as I didn't get this kind of problem before today and things started to go wrong without any code change.

Grubba27 commented 1 year ago

This seems to be solved. See this reply

fatnaelbassraoui commented 4 months ago

Sure! @Grubba27 hello i have a issue can you help me please? Cannot convert undefined or null to object TypeError: Cannot convert undefined or null to object