Skip to content

Conversation

bergie
Copy link
Contributor

@bergie bergie commented Aug 29, 2025

Description

This PR improves connection lifecycle handling. Especially:

  • Lost connection to device clears any leftover enqueued packets or a running heartbeat
  • Failed configure() due to a cut connection produces a clearer error message
  • In case of lost TCP connection (Node.js only?), queue processing throws instead of running to an endless console.log loop
  • Utils.toDeviceStream was a singleton. This was at the heart of our reconnection problems. Switched to a function that always gives you a new instance

Related Issues

Follow-up on #790

Testing Done

Lots of testing with a local node and manually triggered reboots.

Copy link

vercel bot commented Aug 29, 2025

@bergie is attempting to deploy a commit to the Meshtastic Team on Vercel.

A member of the Team first needs to authorize it.

@bergie bergie changed the title WIP: Connection robustness improvements Connection robustness improvements Aug 29, 2025
Copy link
Collaborator

@danditomaso danditomaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of syntax errors.

}
this._heartbeatIntervalId = setInterval(() => {
this.heartbeat();
this.heartbeat().catch(() => {});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a catch statement we should be returning or throwing an error or remove the empty catch statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside an interval, so it was crashing to UncaughtException. Not many options we could do there... we could maybe log it, or emit an event.

Types.DeviceStatusEnum.DeviceDisconnected,
this.isTimeoutOrAbort(error) ? "write-timeout" : "write-error",
);
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix the lint rule for this, to be explicit we should return undefined as that is what an empty return does

Copy link

vercel bot commented Aug 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
web-test Ready Ready Preview Comment Sep 4, 2025 5:08pm

Copy link
Collaborator

@danditomaso danditomaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@danditomaso
Copy link
Collaborator

@bergie It looks like the checks for this are failing on some missing formatting. If you run pnpm run check:fix from the root of the repo, and commit the changes you should be good to go

@bergie bergie force-pushed the connection_robustness branch from 0b14911 to d6cfd14 Compare September 4, 2025 13:11
@bergie
Copy link
Contributor Author

bergie commented Sep 4, 2025

@bergie It looks like the checks for this are failing on some missing formatting. If you run pnpm run check:fix from the root of the repo, and commit the changes you should be good to go

Done

@bergie
Copy link
Contributor Author

bergie commented Sep 4, 2025

It seems bdfb8c5 was quite key. Since we had a singleton for the toDevice transform stream, once it was closed, it would fail also on subsequent connection attempts.

@danditomaso danditomaso merged commit bcdda8b into meshtastic:main Sep 4, 2025
3 of 4 checks passed
@bergie bergie deleted the connection_robustness branch September 4, 2025 17:09
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.

2 participants