Skip to content

fix: triggerUncaughtException(err, true /* fromPromise */); - #50

Open
webbrain-one wants to merge 1 commit into
connorads:masterfrom
webbrain-one:webbrain/issue-47
Open

fix: triggerUncaughtException(err, true /* fromPromise */);#50
webbrain-one wants to merge 1 commit into
connorads:masterfrom
webbrain-one:webbrain/issue-47

Conversation

@webbrain-one

Copy link
Copy Markdown

Closes #47

Wrap the Playwright wait for the Fanatic badge so a missing or hidden badge does not cause an uncaught promise rejection, allowing the script to continue capturing badge progress.
@connorads

Copy link
Copy Markdown
Owner

Hey, thanks for the PR!

Could you show it working? Log output or a screenshot from a real run would settle it.

Heads up that you'll need an account that hasn't earned Fanatic to reach this branch at all, since if (!awarded) is skipped otherwise. Easiest way is ALTERNATIVE_URL pointed at a Stack Exchange site where you don't have the badge yet.

Two things I'm unsure about:

  • The commit message says it wraps the wait so a missing badge doesn't cause an uncaught rejection, but I don't see a try/catch and waitForSelector is unchanged. Wouldn't it still crash the same way?

  • Removing page.click('.js-select-badge-container') looks like it breaks this. That selector was #badge-card-settings before SO renamed it (see Track badge progress聽#9 and Fix css selector that changed on SO side聽#33), and per SO's own user.en.js the picker contents are AJAX-loaded on click:

    load: function ({container: e, userId: t, ...}) {
      e.data("loaded") || $.get("/users/activity/next-badge-popup?userId=" + t + ...)
        .done(function (t) { e.data("loaded", !0).empty().append(t) })
    }

    So [data-badge-database-name="Fanatic"] isn't in the DOM at all until that click happens, and waitForSelector would time out exactly as in triggerUncaughtException(err, true /* fromPromise */);聽#47.

Using page.goto instead of clicking .s-user-card is a nice simplification though, we already have userid by that point. Happy to be proven wrong by a run.

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.

triggerUncaughtException(err, true /* fromPromise */);

2 participants