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

Bento: Coreify deserializeMessage #35563

Merged
merged 7 commits into from
Aug 11, 2021
Merged

Conversation

caroqliu
Copy link
Contributor

@caroqliu caroqliu commented Aug 6, 2021

The helper is used in a number of Bento components including amp-twitter, amp-facebook, and amp-embedly-card.

@lgtm-com
Copy link

lgtm-com bot commented Aug 6, 2021

This pull request introduces 1 alert when merging 14186a7 into 90afe34 - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@caroqliu caroqliu marked this pull request as ready for review August 6, 2021 21:09
src/3p-frame-messaging.js Outdated Show resolved Hide resolved
});

it('should return null if failed to parse the input', () => {
const errorStub = env.sandbox.stub(dev(), 'error');
expectAsyncConsoleError(/MESSAGING: Failed to parse message/i, 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

/cc @rsimha to confirm this is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

The usage on line 608 looks correct, but I don't see the next couple lines doing any waiting. Should there be an await to ensure that the asynchronous error doesn't leak from the test? Or are the operations synchronous, with the errors thrown asynchronously?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's sync, with the error thrown async.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying. In that case, this code should work as written. Any issues will be caught by the "Local Unit Tests" job on CircleCI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the test is failing due to the error: https://app.circleci.com/pipelines/github/ampproject/amphtml/14320/workflows/8164eb80-8a86-4022-9fe8-6edb28601c2c/jobs/239541

This case expects that the function will return null even if given malformed json, which should cause the async error. Any tips on how to debug?

Copy link
Contributor

Choose a reason for hiding this comment

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

Opened #35605 to fix.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Copy link
Contributor

@rcebulko rcebulko left a comment

Choose a reason for hiding this comment

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

Nice! Is the plan to move it into #core somewhere?

@caroqliu caroqliu added this to In progress in Bento Aug 9, 2021
@caroqliu
Copy link
Contributor Author

Nice! Is the plan to move it into #core somewhere?

It can be moved but I wasn't sure if it is urgent to do so given that the larger file may be moved eventually. Is it generally preferred for (1) files to import either from src/foo or #core/foo but not both, or (2) for src/foo to contain non-core code only?

@rcebulko
Copy link
Contributor

Nice! Is the plan to move it into #core somewhere?

It can be moved but I wasn't sure if it is urgent to do so given that the larger file may be moved eventually. Is it generally preferred for (1) files to import either from src/foo or #core/foo but not both, or (2) for src/foo to contain non-core code only?

If I'm reading the imports correctly, this entire file should be safe/ready to import into #core. For the sake of managing merge conflicts/keeping this PR small, I'd suggest getting this in, then moving it+test into core/updating the files (~41) that import from it. Happy to help with this

@caroqliu
Copy link
Contributor Author

Nice! Is the plan to move it into #core somewhere?

It can be moved but I wasn't sure if it is urgent to do so given that the larger file may be moved eventually. Is it generally preferred for (1) files to import either from src/foo or #core/foo but not both, or (2) for src/foo to contain non-core code only?

If I'm reading the imports correctly, this entire file should be safe/ready to import into #core. For the sake of managing merge conflicts/keeping this PR small, I'd suggest getting this in, then moving it+test into core/updating the files (~41) that import from it. Happy to help with this

Sounds good! I'll follow up with this. Thanks.

import {internalListenImplementation} from './core/dom/event-helper-listen';
import {rethrowAsync} from './core/error';
Copy link
Contributor

@rcebulko rcebulko Aug 10, 2021

Choose a reason for hiding this comment

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

nit: Let's update all of these to use #core instead of ./core. It'll make moving the file a no-diff operation later. Really all files using this notation should be updated, but it hasn't been prioritized yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I was wondering about that when my auto import for rethrowAsync put it in #core but the others were in ./core. Updated :)

rcebulko added a commit to rcebulko/amphtml that referenced this pull request Aug 10, 2021
rcebulko added a commit to rcebulko/amphtml that referenced this pull request Aug 10, 2021
rcebulko added a commit to rcebulko/amphtml that referenced this pull request Aug 10, 2021
rcebulko added a commit that referenced this pull request Aug 10, 2021
* Update src/*.js to import via alias

* Revert 3p-frame-messaging (updated in #35563)

* Fix rebase error
jridgewell added a commit to jridgewell/amphtml that referenced this pull request Aug 10, 2021
jridgewell added a commit to jridgewell/amphtml that referenced this pull request Aug 10, 2021
jridgewell added a commit to jridgewell/amphtml that referenced this pull request Aug 10, 2021
jridgewell added a commit that referenced this pull request Aug 11, 2021
* Integrate expectAsyncConsoleError with rethrowAsync

Re: #35563

* Cleanup
mszylkowski pushed a commit to mszylkowski/amphtml that referenced this pull request Aug 11, 2021
)

* Integrate expectAsyncConsoleError with rethrowAsync

Re: ampproject#35563

* Cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Bento
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants