Skip to content

feat: monkey-patch MessagePort onproperties#34610

Closed
JiaLiPassion wants to merge 1 commit intoangular:masterfrom
JiaLiPassion:messageport
Closed

feat: monkey-patch MessagePort onproperties#34610
JiaLiPassion wants to merge 1 commit intoangular:masterfrom
JiaLiPassion:messageport

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Contributor

Close #34581

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #34581

What is the new behavior?

monkey-patch MessagePort.onmessage/onmessageerror properties.

Does this PR introduce a breaking change?

  • Yes
  • No

@JiaLiPassion JiaLiPassion requested a review from a team January 2, 2020 06:50
@JiaLiPassion JiaLiPassion added the area: zones Issues related to zone.js label Jan 2, 2020
@ngbot ngbot Bot added this to the needsTriage milestone Jan 2, 2020
Comment thread packages/zone.js/test/browser/messageport.spec.ts Outdated
Copy link
Copy Markdown
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

Approved with some nits.

Also the tests are failing, usually we try to get CI green before doing code review.

Comment thread packages/zone.js/lib/browser/message-port.ts Outdated
Comment thread packages/zone.js/test/browser/messageport.spec.ts Outdated
@mhevery mhevery added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: merge The PR is ready for merge by the caretaker labels Feb 26, 2020
@ngbot
Copy link
Copy Markdown

ngbot Bot commented Feb 26, 2020

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci/angular: size" is failing
    failure status "ci/circleci: test_ivy_aot" is failing
    pending missing required labels: PR target: *
    pending forbidden labels detected: PR action: cleanup
    pending status "ci/circleci: components-repo-unit-tests" is pending
    pending status "ci/circleci: test" is pending
    pending status "ci/circleci: test_aio" is pending
    pending status "ci/circleci: test_aio_local" is pending
    pending status "ci/circleci: test_aio_local_viewengine" is pending
    pending status "google3" is pending
    pending missing required status "ci/circleci: publish_snapshot"

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@mhevery mhevery added target: patch This PR is targeted for the next patch release target: major This PR is targeted for the next major release and removed action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Feb 26, 2020
@JiaLiPassion JiaLiPassion force-pushed the messageport branch 2 times, most recently from cc92096 to bd60b2b Compare February 26, 2020 06:24
@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@mhevery , thanks, the test failed because there is a flaky cases, I fixed it here, #35679

@JiaLiPassion JiaLiPassion removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Mar 5, 2020
@mhevery
Copy link
Copy Markdown
Contributor

mhevery commented Mar 6, 2020

presubmit

@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Mar 6, 2020
@matsko matsko closed this in 1882451 Mar 9, 2020
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Mar 9, 2020
…ssageerror) (angular#34610)"

This reverts commit 1882451.

Reason: breaks some g3 targets.
matsko pushed a commit that referenced this pull request Mar 9, 2020
…ssageerror) (#34610)" (#35973)

This reverts commit 1882451.

Reason: breaks some g3 targets.

PR Close #35973
@AndrewKushnir
Copy link
Copy Markdown
Contributor

AndrewKushnir commented Mar 9, 2020

FYI, the changes from this PR caused some failures in g3, so the changes were reverted from master (in 71309d2). I'm re-opening this ticket.

cc @matsko

@AndrewKushnir AndrewKushnir reopened this Mar 9, 2020
@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@AndrewKushnir , could you tell me more information about the failure in g3, because this PR should have no impact for the current code, this PR just build a new bundle , and this bundle will not be loaded by default. Thanks!

@AndrewKushnir AndrewKushnir added state: blocked and removed action: merge The PR is ready for merge by the caretaker labels Mar 9, 2020
@AndrewKushnir
Copy link
Copy Markdown
Contributor

AndrewKushnir commented Mar 9, 2020

Hi @JiaLiPassion,

If I understand correctly, all files in the browser folder are included (except excluded ones), here is a snippet from the Angular BUILD file in g3:

ts_library(
    name = "zonejs_lib",
    srcs = glob(
        [
            "packages/zone.js/lib/browser/*.ts",
        ],
        exclude = [
            "packages/zone.js/lib/browser/rollup-*.ts",
            "packages/zone.js/lib/browser/shadydom.ts",
            "packages/zone.js/lib/browser/utils.ts",
            "packages/zone.js/lib/browser/webapis-*.ts",
        ],
    ) + [
        "packages/zone.js/lib/zone-spec/long-stack-trace.ts",
        "packages/zone.js/lib/zone-spec/wtf.ts",
    ],
    ...
)

So the newly added packages/zone.js/lib/browser/message-port.ts was also included and as a result affected some code.

Should it be in the exclude list?

Thank you.

@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@AndrewKushnir , oh, yes, I see the code snippet also exclude webapi-* so this messageport should also be excluded. This is an optional packages, so I think g3 doesn't need this file to be compiled.
Thanks.

@AndrewKushnir
Copy link
Copy Markdown
Contributor

Hi @JiaLiPassion, thanks for the update. Could you please rebase this PR, so that we re-run CI again and I'll try to run presubmit (excluding the file) in g3 again. Thank you.

@AndrewKushnir AndrewKushnir added the action: presubmit The PR is in need of a google3 presubmit label Mar 11, 2020
@JiaLiPassion JiaLiPassion reopened this Mar 11, 2020
@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@AndrewKushnir , sure, I have rebased this PR, please review, thanks!

Monkey patch `MessagePort.prototype.onmessage` and `MessagePort.prototype.onmessageerror` to make
these properties's value(callback function) run in the zone when these value are set.
@AndrewKushnir
Copy link
Copy Markdown
Contributor

@JiaLiPassion thanks for the update.

FYI, in order to run tests for ZoneJS changes that are in the merge queue, I've combined 4 ZoneJS PRs into one: #36043. Note: the #36043 PR is for testing purposes only and the changes will land in the corresponding PRs once g3 testing is completed.

Thank you.

@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@AndrewKushnir, got it, thank you!

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Mar 16, 2020
@AndrewKushnir
Copy link
Copy Markdown
Contributor

FYI, changes in this PR were tested against g3 as a part of #36043, using Global TAP run, which was successful. Thank you.

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: zones Issues related to zone.js cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zone.js doesn't monkey patch MessagePort#onmessage

5 participants