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

Feat/render errors in modal #57

Merged
merged 16 commits into from
Jun 6, 2024

Conversation

0x4007
Copy link
Member

@0x4007 0x4007 commented Jun 4, 2024

Resolves #50

  • Also shows an error icon in the modal header to distinguish between normal behavior and error display behavior.
  • Manually tested normal errors and rejected promises.
    • Note that you can't pass in an error in the console, as it runs in an isolated runtime apparently, and the window.onerror event does not capture it. Instead you need to add a throw new Error() inside the code for testing.

localhost_8080_

@0x4007 0x4007 requested a review from pavlovcik as a code owner June 4, 2024 10:46
@ubiquibot ubiquibot bot closed this Jun 4, 2024
@0x4007 0x4007 reopened this Jun 4, 2024
@ubiquity-os-deployer
Copy link

ubiquity-os-deployer bot commented Jun 4, 2024

@0x4007 0x4007 requested a review from gentlementlegen June 4, 2024 10:51
@0x4007
Copy link
Member Author

0x4007 commented Jun 4, 2024

Reviewed the spec and realized I need a Cypress test. Working on figuring this out now.

@0x4007 0x4007 marked this pull request as draft June 4, 2024 11:28
@0x4007
Copy link
Member Author

0x4007 commented Jun 4, 2024

The last successful run of Cypress was three months ago with a single test, so it appears as though they were never stable in the first place @gentlementlegen

Perhaps the Cypress tests should all be fixed as part of a separate task.

@0x4007 0x4007 mentioned this pull request Jun 4, 2024
@0x4007 0x4007 removed the request for review from pavlovcik June 4, 2024 12:02
@0x4007 0x4007 marked this pull request as ready for review June 4, 2024 12:02
@0x4007 0x4007 requested a review from rndquu June 4, 2024 12:39
@gentlementlegen
Copy link
Member

gentlementlegen commented Jun 5, 2024

@0x4007 Usual test cases works fine, although I do not get any modal on network failures, I simulated them an just got a blank screen, do not know if that's wanted. c.f. screenshot
image

Unrelated issue but users that do not have a name set have a blank display next to them, might better use the login field
image


Ran tests locally, the new test fails with error

AssertionError: Timed out retrying after 4000ms: expected '<div.preview-header>' to be 'visible'

This element `<div.preview-header>` is not visible because its parent `<div.preview>` has CSS property: `opacity: 0`

Will test locally by merging my fix branch and see if tests are resolved.


The new added test also fails in the other branch. Will fix after merge.

AssertionError: Timed out retrying after 4000ms: expected '<div.preview-header>' to contain 'Something went wrong'

@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

@0x4007 Usual test cases works fine, although I do not get any modal on network failures, I simulated them an just got a blank screen, do not know if that's wanted.

How exactly did you simulate? Any rejected promises within the code (not via the console/repl) throw the modal.

Unrelated issue but users that do not have a name set have a blank display next to them, might better use the login field

You can file a new issue.

Ran tests locally, the new test fails with error

AssertionError: Timed out retrying after 4000ms: expected '<div.preview-header>' to be 'visible'

This element `<div.preview-header>` is not visible because its parent `<div.preview>` has CSS property: `opacity: 0`

Tests don't work. This is expected.

@gentlementlegen
Copy link
Member

@0x4007 I blocked the requests within the browser to make them fail. You can also simulate by turning the network "offline" so all the requests fail as well.

I will file a new issue!

All the tests work except yours, will fix in the other pull request.

@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

@0x4007 I blocked the requests within the browser to make them fail. You can also simulate by turning the network "offline" so all the requests fail as well.

Will check.

All the tests work except yours, will fix in the other pull request.

This sounds like an implicit approval. Can you merge?

@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

Just got it! The try/catches were catching and not letting some errors propagate to the top. I was able to replicate what you did by setting my network to "offline" while loading.

localhost_8080_ (1)

@gentlementlegen
Copy link
Member

@0x4007 When accessing the page and being logged-out, I have this being displayed:

image

Is it intended?

@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

I believe that this is technically correct, because I interpret it as a bug with the cache.

I interpret as that you have some privileged access to some information when you are logged in, which is partially retained in the cache (we have two layers, the preview and the full details.)

When you are logged out, the cache is not reinitialized correctly, leading to this error.

These are my assumptions only based on my experience dealing with the cache problems some time ago when I first implemented it.


image

Running it locally I see these errors.

Based on the latest, I assume there is something in the cache that suggests you are logged in, and then it tries to request the current logged in user details. Because you are not currently logged in (I believe the endpoint is generic, literally like api.github.com/user, but includes your auth token in the headers) the endpoint says you aren't actually a real logged in user.

So in conclusion, any errors shown by the modal I am confident are real errors.

@0x4007 0x4007 marked this pull request as draft June 5, 2024 06:57
@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

Just stumbled upon this will require more investigation. Should have been caught by window.onerror

image

@gentlementlegen
Copy link
Member

@0x4007 But if you simply access the website as a logged-out user, should this be displayed? I know that this call will fail for anyone logged-out / not part of the org. It's an expected error because Octokit throws with a 404. Maybe should be caught and not thrown?

@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

@0x4007 But if you simply access the website as a logged-out user, should this be displayed? I know that this call will fail for anyone logged-out / not part of the org. It's an expected error because Octokit throws with a 404. Maybe should be caught and not thrown?

We need to not make the network request unless the user is logged in. What I'm suggesting is that this is an actual error, and should be fixed as part of a separate task.


Off topic but:

Use window.onerror to catch unhandled errors globally, but it won’t catch errors from within async functions or certain other contexts.

So I'm going in and wrapping all of the other event handlers now with this modal.

@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

The theory is correct. Just need to wrap all of the event handlers. Almost finished...

127 0 0 1_8080_

@0x4007
Copy link
Member Author

0x4007 commented Jun 5, 2024

Good to go!

As a heads up, I especially handled the rate limiting and automatic logout problems at 9243a6e I don't have a screenshot of that unfortunately but I do have of the other error:

127 0 0 1_8080_ (1)

@0x4007 0x4007 marked this pull request as ready for review June 5, 2024 08:39
const reset = core.data.resources.core.reset;
// Mark private issues
const privateIssuesWithFlag = privateIssues.map((issue) => {
return issue;
Copy link
Member Author

Choose a reason for hiding this comment

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

Just realized this is unnecessary in its current form.

@0x4007 0x4007 merged commit 5c50b2c into ubiquity:development Jun 6, 2024
1 check passed
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.

Error toast is not shown properly
3 participants