Skip to content

Comments

Fix null reference error in waitError when act.result is undefined#3

Open
wittjeff wants to merge 1 commit intojrpool:mainfrom
wittjeff:fix-wait-error-null-result
Open

Fix null reference error in waitError when act.result is undefined#3
wittjeff wants to merge 1 commit intojrpool:mainfrom
wittjeff:fix-wait-error-null-result

Conversation

@wittjeff
Copy link

@wittjeff wittjeff commented Feb 5, 2026

Summary

Fixes a crash when waitError is called before act.result has been initialized.

Problem

The waitError function assumes act.result already exists:

const waitError = (page, act, error, what) => {
  console.log(`ERROR waiting for ${what} (${error.message})`);
  act.result.found = false;  // 💥 Crashes if act.result is undefined
  // ...
};

When a wait error occurs before act.result is set, this crashes with:

TypeError: Cannot set property 'found' of undefined

Solution

Add a nullish coalescing assignment to initialize act.result if needed:

act.result ??= {};
act.result.found = false;

Testing

This fix has been running in production at YRA Monitor via patch-package without issues.

🤖 Generated with Claude Code

The waitError function assumes act.result is already initialized, but
this is not always the case. When a wait error occurs before act.result
is set, the function crashes with:

  TypeError: Cannot set property 'found' of undefined

This adds a nullish coalescing assignment to initialize act.result to
an empty object if it's undefined before setting properties on it.
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