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

cross-document error propagation #755

Merged
merged 9 commits into from
Mar 14, 2024
Merged

Conversation

turbocrime
Copy link
Contributor

@turbocrime turbocrime commented Mar 14, 2024

should now convey serialized errors all the way to the client in every situation

no size diff

Screenshot 2024-03-13 at 17 17 59

should help with #751 but there will be another underlying cause

@turbocrime turbocrime requested a review from jessepinho March 14, 2024 00:13
@turbocrime turbocrime force-pushed the turbocrime/751-error-prop branch from 98d64d7 to 85a0110 Compare March 14, 2024 00:20
Copy link
Contributor

@jessepinho jessepinho left a comment

Choose a reason for hiding this comment

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

Hey, this seems to introduce regressions from #742 (which was merged earlier today). Can you please make sure those 3 cases are working first?

@turbocrime
Copy link
Contributor Author

okay i got confused by the broken HMR :[ i thought i wasn't seeing the issue, because it kinda works depending on where you edit things

wip pushed up i'll work on it tomorrow. annoyingly i think errors are propagating but they're getting detyped when they cross the dom message channel

@turbocrime turbocrime force-pushed the turbocrime/751-error-prop branch from eaf1024 to 67d6b95 Compare March 14, 2024 18:38
Copy link
Contributor Author

Choose a reason for hiding this comment

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

popup responses may be absent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

offscreen now uses ConnectError to serialize failures, and handles more failures

Copy link
Contributor Author

Choose a reason for hiding this comment

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

popup utility catches a closed window into an absent response

Copy link
Contributor Author

Choose a reason for hiding this comment

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

slice logic no longer necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't have ConnectError in this scope, so still doing string detection. i think if we want to detect actual codes instead of the code annotated in the message, that should be a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe unnecessary to change, but racing every build result with cancel was excessive and caused more throws than necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now using ConnectError in content scripts

packages/transport-dom/src/create.ts Show resolved Hide resolved
@turbocrime turbocrime requested a review from jessepinho March 14, 2024 19:36
@turbocrime turbocrime force-pushed the turbocrime/751-error-prop branch from 7eb71bf to 0cc0314 Compare March 14, 2024 19:41
@turbocrime turbocrime changed the title offscreen error propagation cross-document error propagation Mar 14, 2024
Copy link
Contributor

@jessepinho jessepinho left a comment

Choose a reason for hiding this comment

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

Hey so, again, there's some very specific niche knowledge in here about messaging that makes it impossible to really review this without a more thorough PR description or inline comments. I added a few questions inline — if you can explain those, then I can give it a final review. But please do this before requesting a review in the future, because otherwise I have to do multiple rounds of reviews.

apps/extension/src/approve-origin.ts Outdated Show resolved Hide resolved
packages/transport-dom/src/create.ts Show resolved Hide resolved
packages/transport-dom/src/create.ts Show resolved Hide resolved
apps/extension/src/popup.ts Show resolved Hide resolved
packages/transport-chrome/session-client.ts Show resolved Hide resolved
apps/extension/src/popup.ts Show resolved Hide resolved
@turbocrime turbocrime requested a review from jessepinho March 14, 2024 20:50
Copy link
Contributor

@jessepinho jessepinho left a comment

Choose a reason for hiding this comment

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

ship it!

@turbocrime turbocrime merged commit 77ae311 into main Mar 14, 2024
6 checks passed
@turbocrime turbocrime deleted the turbocrime/751-error-prop branch March 14, 2024 21:02
@@ -52,18 +52,19 @@ export const approveOrigin = async ({

if ('error' in res)
throw errorFromJson(res.error as JsonValue, undefined, ConnectError.from(res));
else if (res.data != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two things I think we should try to avoid:

  • The equality operators that do casting (aka == and !=). They are largely considered to be bad aspects of the javascript. It has the chance to not feel so logical. For example: '0' == false. This will return true. For these, we should always stick to the strict equals version === and !==.
  • Null. Many folks consider this also to be a mistake in the javascript language given there are two primitives that basically represent that kind of state. Think we should always default to undefined where we can. Though, I know in some places (like loaders), they require nulls.

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