Skip to content

Connection robustness improvements#813

Merged
danditomaso merged 12 commits into
meshtastic:mainfrom
bergie:connection_robustness
Sep 4, 2025
Merged

Connection robustness improvements#813
danditomaso merged 12 commits into
meshtastic:mainfrom
bergie:connection_robustness

Conversation

@bergie

@bergie bergie commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

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.

@vercel

vercel Bot commented Aug 29, 2025

Copy link
Copy Markdown

@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

@danditomaso danditomaso left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread packages/core/src/meshDevice.ts Outdated
}
this._heartbeatIntervalId = setInterval(() => {
this.heartbeat();
this.heartbeat().catch(() => {});

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@vercel

vercel Bot commented Aug 31, 2025

Copy link
Copy Markdown

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

@danditomaso danditomaso left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

bergie commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

@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

bergie commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

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