Closed sentry-io[bot] closed 9 months ago
Checking the device model, on a cursory glance, it looks like a device should always have a team. Can anyone explain why we'd be receiving status events from devices without teams? Or are they perhaps just not being loaded by the db request?
@Pezmc does the sentry distinguish dev time issues (i.e. me on my dev machine, breaking things) from real world (out there / customers) issues?
@Steve-Mcl It logs the environment and we typically filter out issues raised in development, this one in question has happened 3200 in production since December the 12th.
There are a number of devices still in the database that were not deleted when the team was deleted.
Seems like we are still getting status check-ins from them then!
I have checked through the calls to app.comms.devices.sendCommand
via sendDeviceUpdateCommand
in forge/app/node_modules/@flowforge/flowforge/forge/db/controllers/Device.js"
@ line 77
As far as I can see device
is always a fully loaded model (e.g. loaded via await app.db.models.Device.byId(targetDevice.id)
) with the required associations
So if these ARE orphaned devices (no team associated) we should probably contain that?
Perhaps something like:
if (device.Team) {
app.comms.devices.sendCommand(device.Team.hashid, device.hashid, 'update', payload)
} else {
// reload the device with the team association
const fullDevice = await app.db.models.Device.byId(device.id)
if (!fullDevice || !fullDevice.Team) {
app.log.warn(`Failed to send update command to device ${device.hashid} as it has no team association`)
return
}
app.comms.devices.sendCommand(fullDevice.Team.hashid, fullDevice.hashid, 'update', payload)
}
It would at least:
sendCommand
As for orphaned devices, they should be picked up by #2569
Okay - I got our sentry issues mixed up. This PR addresses an error message we haven't seen in production for over a month. This is not the one I thought it was.
Sentry Issue: FLOWFUSE-BACKEND-2A