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

Pass irrecoverable context to ws handler #7154

Merged

Conversation

illia-malachyn
Copy link
Contributor

Closes #7109

@illia-malachyn illia-malachyn requested a review from a team as a code owner March 13, 2025 15:10
@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Project coverage is 41.26%. Comparing base (82d7f1d) to head (fe9ff2f).
Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
cmd/util/cmd/run-script/cmd.go 0.00% 10 Missing ⚠️
engine/access/rpc/engine.go 0.00% 3 Missing ⚠️
engine/access/rest/websockets/handler.go 0.00% 2 Missing ⚠️
engine/access/rest/router/router.go 0.00% 1 Missing ⚠️
engine/access/rest/server.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7154   +/-   ##
=======================================
  Coverage   41.25%   41.26%           
=======================================
  Files        2170     2170           
  Lines      190050   190109   +59     
=======================================
+ Hits        78409    78451   +42     
- Misses     105097   105114   +17     
  Partials     6544     6544           
Flag Coverage Δ
unittests 41.26% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

api := &api{
chainID: chainID,
vm: vm,
ctx: ctx,
storageSnapshot: storageSnapshot,
}

irrCtx, _ := irrecoverable.WithSignaler(context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not a good practice to ignore the error channel from irrecoverable contexts since that could end up ignoring an exception!

This is the preferred way to handle it
https://github.com/onflow/flow-go/pull/7155/files#diff-29dbb5e7e1c4ab893e43c26264cbe29048076a9bf049a466032f11c498572717R108-R116

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem here is that we do not have any parent irrecoverable context, just a regular context. Should we just log.Fatal().Err(err) in such a case?

Copy link
Contributor

Choose a reason for hiding this comment

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

yea, log.Fatal() the the best alternative

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done it. Can you make sure everything is ok in the new version?

@Guitarheroua Guitarheroua self-requested a review March 14, 2025 13:00
Copy link
Contributor

@Guitarheroua Guitarheroua left a comment

Choose a reason for hiding this comment

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

Other than Peter`s comment, it looks good to me!

@illia-malachyn illia-malachyn force-pushed the illia-malachyn/7109-add-irrecoverable-ctx-to-ws-controller branch from 9516d3e to a659b1b Compare March 21, 2025 10:39
@illia-malachyn
Copy link
Contributor Author

Sorry, I rebased on top of master instead of merging by mistake, so I had to force-push.

api := &api{
chainID: chainID,
vm: vm,
ctx: ctx,
storageSnapshot: storageSnapshot,
}

irrCtx, errCh := irrecoverable.WithSignaler(context.Background())
go func() {
err := modutil.WaitError(errCh, nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use nil for the done channel. nil channel in the select statement is never selected.

@peterargue peterargue enabled auto-merge March 21, 2025 17:51
@peterargue peterargue added this pull request to the merge queue Mar 21, 2025
Merged via the queue into master with commit 1739d1d Mar 21, 2025
56 checks passed
@peterargue peterargue deleted the illia-malachyn/7109-add-irrecoverable-ctx-to-ws-controller branch March 21, 2025 18:32
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.

[Access] The TODO Context should be changed in WebSocket Handler
4 participants