Skip to content

Fixed running retryFailedStep inside tryTo #4831

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

Merged
merged 12 commits into from
Feb 10, 2025
Merged

Conversation

DavertMik
Copy link
Contributor

@DavertMik DavertMik commented Feb 6, 2025

Fixed regression when retryFailedStep was enabled inside tryTo block

  • moved switch from env var to store
  • added autoRetry store setting
  • fixed and adjusted tests
  • changed how to disable test for retryFailedStep

Other changes

  • improved check messages
  • fixed subtitles test
  • fixed TS definitions for Step
  • within introduced as part of effects module (should be moved to effects in 3.8/4.0)

@DavertMik DavertMik requested a review from kobenguyent February 6, 2025 06:36
Comment on lines +135 to +142
checks.setup = true
for (const helper of Object.values(helpers)) {
try {
if (helper._beforeSuite) await helper._beforeSuite(suite)
if (helper._before) await helper._before(test)
} catch (err) {
err.message = `${helper.constructor.name} helper: ${err.message}`
if (checks.setup instanceof Error) err.message = `${err.message}\n\n${checks.setup?.message || ''}`.trim()
Copy link
Collaborator

Choose a reason for hiding this comment

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

out of curiosity, the line 135 defines as a boolean and then line 143 we assign an Error to it.
Shall we assign err.message to checks.setup?.message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

the value of setup is boolean|| Error

if it is error, we pick a previous message and append to current error
if it is true but we fail, we write error
if it is true and never fail we have true

See line 170

} catch (err) {
err.message = `${helper.constructor.name} helper: ${err.message}`
if (checks.teardown instanceof Error) err.message = `${err.message}\n\n${checks.teardown?.message || ''}`.trim()
checks.teardown = err
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above concern

lib/effects.js Outdated
return recorder.add(
sessionName,
() => {
recorder.session.start(sessionName)
store.tryTo = true
hasAutoRetriesEnabled = store.autoRetries
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about isAutoRetriesEnabled?

@@ -484,7 +484,7 @@ class Playwright extends Helper {
this.currentRunningTest = test

recorder.retry({
retries: process.env.FAILED_STEP_RETRIES || 3,
retries: test?.opts?.conditionalRetries || 3,
Copy link
Collaborator

Choose a reason for hiding this comment

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

as you touched this, what do you think if we store default retries = 3 in Store?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then we need a better name for it...
this handles a very strange edge cases in Playwright / Puppeteer
I don't know what name in store is applicable for this and in which other contexts can be used

} else {
args.push(JSON.stringify(arg).slice(0, 300))
} else if (arg) {
args.push((JSON.stringify(arg) || '').slice(0, 300))
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there any chance JSON.stringify(arg) is null or undefined then '' is used here?

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'd rather not print undefined here...

Not sure about null

But I'd rather not, it's not readable...

@DavertMik DavertMik merged commit 2d902fd into 3.x Feb 10, 2025
12 checks passed
@DavertMik DavertMik deleted the fix/retry-tryto-regression branch February 10, 2025 00:25
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.

3 participants