Skip to content

Conversation

@samihusseingit
Copy link
Contributor

Kindly review the commit and allow if it is valid.

IT resolves the issue for me as for some odd reason, the Results retrieved could be null, and then you see something like this and the application crashes.

got data-received event, requesting reload
2022-06-29T09:04:17.746228+00:00 app[web.1]: Got results null
2022-06-29T09:04:17.749245+00:00 app[web.1]: /app/node_modules/mongodb/lib/utils.js:106
2022-06-29T09:04:17.749246+00:00 app[web.1]: throw err;
2022-06-29T09:04:17.749246+00:00 app[web.1]: ^
2022-06-29T09:04:17.749247+00:00 app[web.1]:
2022-06-29T09:04:17.749247+00:00 app[web.1]: TypeError: Cannot read property '_id' of null
2022-06-29T09:04:17.749247+00:00 app[web.1]: at hasId (/app/lib/server/cache.js:47:41)
2022-06-29T09:04:17.749248+00:00 app[web.1]: at arrayFilter (/app/node_modules/lodash/lodash.js:582:11)
2022-06-29T09:04:17.749248+00:00 app[web.1]: at Function.filter (/app/node_modules/lodash/lodash.js:9199:14)
2022-06-29T09:04:17.749249+00:00 app[web.1]: at filterForAge (/app/lib/server/cache.js:46:16)
2022-06-29T09:04:17.749249+00:00 app[web.1]: at mergeCacheArrays (/app/lib/server/cache.js:37:23)
2022-06-29T09:04:17.749249+00:00 app[web.1]: at Stream.dataChanged (/app/lib/server/cache.js:83:30)
2022-06-29T09:04:17.749250+00:00 app[web.1]: at Stream.emit (events.js:314:20)
2022-06-29T09:04:17.749250+00:00 app[web.1]: at /app/lib/server/websocket.js:223:29
2022-06-29T09:04:17.749251+00:00 app[web.1]: at executeCallback (/app/node_modules/mongodb/lib/operations/execute_operation.js:70:5)
2022-06-29T09:04:17.749251+00:00 app[web.1]: at handleCallback (/app/node_modules/mongodb/lib/utils.js:102:55)
2022-06-29T09:04:18.947127+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling" host=samihusseint1d.herokuapp.com request_id=b4273353-c000-46ba-b841-7995df551643 fwd="83.209.194.49" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:17.993106+00:00 heroku[web.1]: State changed from up to crashed
2022-06-29T09:04:17.759370+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=websocket&sid=My6_duaUMjdIWCPQAAAA" host=samihusseint1d.herokuapp.com request_id=20b718bc-ebc4-4e72-a515-7fb99549c425 fwd="83.209.194.49" dyno=web.1 connect=3ms service=201584ms status=101 bytes=129 protocol=https
2022-06-29T09:04:17.758193+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=websocket&sid=4mZHJdkMJV4_CfnbAAAC" host=samihusseint1d.herokuapp.com request_id=e7d47a58-04d8-4720-8390-34046b448f43 fwd="83.209.194.49" dyno=web.1 connect=2ms service=201541ms status=101 bytes=129 protocol=https
2022-06-29T09:04:19.046559+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=O6kj4BD" host=samihusseint1d.herokuapp.com request_id=2ec00e3c-81ea-4eec-b7ab-e56073e73b3b fwd="83.209.194.49" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:19.069916+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=O6kj4QZ" host=samihusseint1d.herokuapp.com request_id=5a8dd623-4111-4b33-9f5f-2dba2893951c fwd="66.159.215.203" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:21.034298+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=O6kj4gP" host=samihusseint1d.herokuapp.com request_id=b0655939-7fff-4825-9ce4-c2da9ddb9103 fwd="83.209.194.49" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:22.241309+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=O6kj59f" host=samihusseint1d.herokuapp.com request_id=1e6a4fe6-8f7b-4815-b600-c5ca9af715d6 fwd="66.159.215.203" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:22.115552+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling" host=samihusseint1d.herokuapp.com request_id=91d7eb2a-179b-49ed-aeb5-ee3e3cfce862 fwd="83.209.194.49" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:24.115411+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=O6kj5PW" host=samihusseint1d.herokuapp.com request_id=cefb09ea-3348-4865-9fca-4c103e56b56b fwd="83.209.194.49" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:26.316177+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling" host=samihusseint1d.herokuapp.com request_id=18aa38a0-c7ab-49aa-92cd-0e09ea80919d fwd="83.209.194.49" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:28.251692+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=O6kj6dH" host=samihusseint1d.herokuapp.com request_id=24c97c7f-6b1b-4456-8e80-d659fcc9d1db fwd="66.159.215.203" dyno= connect= service= status=503 bytes= protocol=https
2022-06-29T09:04:30.199726+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=O6kj6t1" host=samihusseint1d.herokuapp.com request_id=f142b2c2-c2c7-4c05-a74e-78fb52f889dc fwd="83.209.194.49" dyno= connect= service= status=503 bytes= protocol=https
Autoscroll with outputSave

@sulkaharo sulkaharo changed the base branch from master to dev June 29, 2022 12:24
@sulkaharo
Copy link
Member

Hi! This looks promising! Any idea of what conditions result in Mongo returning a null result?

@sulkaharo
Copy link
Member

Ping @bewest this looks like the right place to patch the crash

@samihusseingit
Copy link
Contributor Author

@sulkaharo I can speak from my case. This happend after updating AndroidAPS + NightScout to the latest master. AndroidAPS version 3.0.0.2.

The reason it happend for my son is because of a Faulty Sensor which was sometimes giving BG readings, and other times not.

But it definitely happened, and this fixes it on our local master branch.

@sulkaharo
Copy link
Member

@bewest Reading the logic for the update function, I suspect what's going on is the update function is being called on data that is not yet in the database and the self-made logic to create an ID and inserting using it is failing. Wonder if the function should be patched to ignore data that's missing the _id and return an error the data is not inserted. Or handle upserts somehow better. I have no idea how AAPS uses the API though. @MilosKozak is AAPS assuming the API implements upserts or just inserts?

@bewest bewest merged commit e72924c into nightscout:dev Jun 30, 2022
@bewest bewest mentioned this pull request Jun 30, 2022
@bewest
Copy link
Member

bewest commented Jun 30, 2022

I've gone ahead and merged this. It would be extremely useful to add some instrumentation to log the data going through the function that causes the crashing behavior. We can use this to create a test case scenario. I'll review the mongo upsert behavior, but this is one area where MongoDB 5 compatibility changes exist in any case.

@justmara
Copy link

wow, nice. will there be new release soon? ;)

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 this pull request may close these issues.

4 participants