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

postorgcreate emitted twice - first hook is emitted without await #1700

Closed
gitfish opened this issue Sep 7, 2022 · 6 comments
Closed

postorgcreate emitted twice - first hook is emitted without await #1700

gitfish opened this issue Sep 7, 2022 · 6 comments
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue

Comments

@gitfish
Copy link

gitfish commented Sep 7, 2022

Summary

This is specific to version 3.x in conjunction with the org plugin. The org plugin will ultimately call the core method scratchOrgCreate (in the org/scratchOrgCreate module). The scratchOrgCreate method will call emitPostOrgCreate (from org/scratchOrgLifecycleEvents) which emits the lifecycle event postorgcreate - this is emitted without an await (so it's properly async). The issue is that the org plugin also emits the lifecycle event postorgcreate, so we're effectively getting the hook firing twice, with the first invocation effectively being in parallel with the second.

Here are the code links to the two firings:

Steps To Reproduce:

  1. Register a postorgcreate hook - a hook that just logs to the console will be sufficient
  2. Create a scratch org

Expected result

A specific postorgcreate hook should only fire once

Actual result

The specific postorgcreate hook fires twice

System Information

  • Which shell/terminal are you using? (e.g. bash, zsh, powershell 5, powershell 7, cmd.exe, etc.)

zsh

  • If you are using sfdx
    • Run sfdx version --verbose --json
  • If you are using sf
    • Run sf version --verbose --json
  • Paste the output here

{
"cliVersion": "sfdx-cli/7.166.1",
"architecture": "darwin-x64",
"nodeVersion": "node-v16.14.0",
"pluginVersions": [
"@oclif/plugin-autocomplete 1.3.0 (core)",
"@oclif/plugin-commands 2.2.0 (core)",
"@oclif/plugin-help 5.1.12 (core)",
"@oclif/plugin-not-found 2.3.1 (core)",
"@oclif/plugin-plugins 2.1.0 (core)",
"@oclif/plugin-update 3.0.0 (core)",
"@oclif/plugin-version 1.1.2 (core)",
"@oclif/plugin-warn-if-update-available 2.0.4 (core)",
"@oclif/plugin-which 2.1.0 (core)",
"alias 2.1.0 (core)",
"apex 1.2.0 (core)",
"auth 2.2.3 (core)",
"community 2.0.1 (core)",
"config 1.4.17 (core)",
"custom-metadata 2.0.0 (core)",
"data 2.1.2 (core)",
"generator 2.0.2 (core)",
"info 2.0.1 (core)",
"limits 2.0.1 (core)",
"org 2.2.0 (core)",
"packaging 1.5.1 (core)",
"schema 2.1.1 (core)",
"signups 1.2.0 (core)",
"source 2.0.13 (core)",
"telemetry 2.0.0 (core)",
"templates 55.1.0 (core)",
"trust 2.0.3 (core)",
"user 2.1.0 (core)",
"@salesforce/sfdx-plugin-lwc-test 1.0.0 (core)",
"salesforce-alm 54.8.1 (core)",
"sfdx-bfs-plugin 2.1.0 (link) /usr/local/lib/node_modules/sfdx-bfs-plugin"
],
"osVersion": "Darwin 21.6.0",
"shell": "zsh",
"rootPath": "/usr/local/lib/node_modules/sfdx-cli"
}

@gitfish gitfish added the investigating We're actively investigating this issue label Sep 7, 2022
@github-actions
Copy link

github-actions bot commented Sep 7, 2022

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@gitfish
Copy link
Author

gitfish commented Sep 7, 2022

I raised this over here as well: https://github.com/forcedotcom/sfdx-core/issues/634, but doesn't look like it's getting much action.

@mshanemc mshanemc added the bug Issue or pull request that identifies or fixes a bug label Sep 8, 2022
@git2gus
Copy link

git2gus bot commented Sep 8, 2022

This issue has been linked to a new work item: W-11724770

@RodEsp
Copy link
Contributor

RodEsp commented Sep 23, 2022

@mshanemc can this be closed now?

@cristiand391
Copy link
Member

This was fixed in sfdx v7.169.1, see release notes: https://github.com/forcedotcom/cli/tree/main/releasenotes/sfdx#71691-sept-22-2022-stable

@gitfish
Copy link
Author

gitfish commented Sep 27, 2022

Hi all - I'm going to open another issue for this. The postorgcreate event will not fire at all anymore, as the lifecycleEventNames prop has been removed (here: salesforcecli/plugin-org#391) which means no listeners are registered for the postorgcreate event (and hence don't fire the hooks). The emit in the core lib will have no effect (unless you've hooked into the lifecycle and added your own listener).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue
Projects
None yet
Development

No branches or pull requests

4 participants