Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout options #207

Merged
merged 5 commits into from
Mar 8, 2024

Conversation

sethterashima
Copy link
Collaborator

Description

Fixes an issue where a handshake would incorrectly be marked as completed if the response came in after the timeout expired.

Adds API and CLI options for adjusting timeouts.

Fixes #194

Type of change

Please select all options that apply to this change:

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Checklist:

Confirm you have completed the following steps:

  • My code follows the style of this project.
  • I have performed a self-review of my code.
  • I have made corresponding updates to the documentation.
  • I have added/updated unit tests to cover my changes.

Seth Terashima added 3 commits March 7, 2024 18:00
The client discards handshake response messages that take too long to
receive because a long delay prevents accurate synchronization between
the client and vehicle clocks.

However, the client still considered the handshake complete after
receiving a delayed response. Vehicles send unsolicited handshake
response messages when they detect a desychronization, and so the
StartSession method relied on this automatic detection without verifying
the result.

This commit fixes the issue by having the client check that a session
was successfully established and retrying as needed.
}
select {
case <-time.After(d.conn.RetryInterval()):
case <-ctx.Done():
Copy link
Contributor

Choose a reason for hiding this comment

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

thank you for not doing a sleep

case d.outbox <- responseBytes:
return
default:
panic(errOutboxFull)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we accept the test context and t.Fatal instead of panic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(1) Can't call t.Fatal from a goroutine (https://pkg.go.dev/testing#B.FailNow); (2) This is called by a stubbed interface implementation, so t can't be passed in the method call, and storing t in structs is, if I recall correctly, Not Recommended.

Both of these issues could be addressed by adding in some plumbing and sending fatal errors through channels, but this doesn't seem worthwhile.

Seth Terashima added 2 commits March 8, 2024 10:14
Timeouts were previously hard-coded. This change allows clients to
specify timeouts dynamically.
Adds timeout command-line options that override the defaults.
@sethterashima sethterashima merged commit b57e560 into teslamotors:main Mar 8, 2024
1 check passed
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.

error : You must provide a private key with -key-name or -key-file to execute this command
2 participants