Skip to content

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

Merged
jrpool merged 2 commits intojrpool:mainfrom
wittjeff:fix-wait-error-null-result
Mar 23, 2026
Merged

Fix null reference error in waitError when act.result is undefined#3
jrpool merged 2 commits intojrpool:mainfrom
wittjeff:fix-wait-error-null-result

Conversation

@wittjeff
Copy link
Copy Markdown

@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

MelvinAkothINGUBU and others added 2 commits February 5, 2026 06:46
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.
@jrpool jrpool merged commit 81b7c6b into jrpool:main Mar 23, 2026
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