Skip to content

Fix hanging commands when webpack and unit tests are used #3212

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

Merged
merged 1 commit into from
Nov 13, 2017

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented Nov 10, 2017

In case you try using npm scripts that come with nativescript-dev-webpack and you also have nativescript-unit-test-runner in your project, the scripts hang. The problem is that nativescript-unit-test-runner has a hook that resolves testExecutionService. In its constructor it sets that analytics broker should not be disposed. However, this is incorrect - it should not be disposed only in case we execute tests with livesync enabled. In order to fix this, move the logic in the commands. This way the hook will not change the disposing of the analytics broker, so once CLI process finishes, analytics broker process will be disconnected and CLI's process will die gracefully.

Fixes: #3164

Also update submodule, where the following change is applied:
Fix execution of hooks outside of process

In case you need a hook to be executed outside of process, you should place correct shebang at the beginning of the file and CLI should spawn it.
However, this is not working at the moment, as when CLI detects that the hook should be spawned, it just does nothing. The code is incorrectly placed inside the if for in process execution. This causes another issue - in case a hook returns a function, which returns falsey value, we decide the hook should be executed outside of process and spawn a new Node.js process to execute the hook. So we execute it twice.

Fix the if-else logic, so the hooks will work correctly.

In case you try using npm scripts that come with `nativescript-dev-webpack` and you also have `nativescript-unit-test-runner` in your project, the scripts hang. The problem is that `nativescript-unit-test-runner` has a hook that resolves `testExecutionService`. In its constructor it sets that analytics broker should not be disposed. However, this is incorrect - it should not be disposed only in case we execute tests with livesync enabled. In order to fix this, move the logic in the commands. This way the hook will not change the disposing of the analytics broker, so once CLI process finishes, analytics broker process will be disconnected and CLI's process will die gracefully.

Also update submodule, where the following change is applied:
Fix execution of hooks outside of process

    In case you need a hook to be executed outside of process, you should place correct shebang at the beginning of the file and CLI should spawn it.
    However, this is not working at the moment, as when CLI detects that the hook should be spawned, it just does nothing. The code is incorrectly placed inside the `if` for in process execution. This causes another issue - in case a hook returns a function, which returns falsey value, we decide the hook should be executed outside of process and spawn a new Node.js process to execute the hook. So we execute it twice.

    Fix the if-else logic, so the hooks will work correctly.
@rosen-vladimirov
Copy link
Contributor Author

run ci

2 similar comments
@rosen-vladimirov
Copy link
Contributor Author

run ci

@rosen-vladimirov
Copy link
Contributor Author

run ci

@rosen-vladimirov
Copy link
Contributor Author

Merging as the failing test is due to infrastructure issues.

@rosen-vladimirov rosen-vladimirov merged commit d4817bc into master Nov 13, 2017
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-hanging-webpack branch November 13, 2017 08:55
rosen-vladimirov added a commit that referenced this pull request Nov 13, 2017
In case you try using npm scripts that come with `nativescript-dev-webpack` and you also have `nativescript-unit-test-runner` in your project, the scripts hang. The problem is that `nativescript-unit-test-runner` has a hook that resolves `testExecutionService`. In its constructor it sets that analytics broker should not be disposed. However, this is incorrect - it should not be disposed only in case we execute tests with livesync enabled. In order to fix this, move the logic in the commands. This way the hook will not change the disposing of the analytics broker, so once CLI process finishes, analytics broker process will be disconnected and CLI's process will die gracefully.

Also update submodule, where the following change is applied:
Fix execution of hooks outside of process

    In case you need a hook to be executed outside of process, you should place correct shebang at the beginning of the file and CLI should spawn it.
    However, this is not working at the moment, as when CLI detects that the hook should be spawned, it just does nothing. The code is incorrectly placed inside the `if` for in process execution. This causes another issue - in case a hook returns a function, which returns falsey value, we decide the hook should be executed outside of process and spawn a new Node.js process to execute the hook. So we execute it twice.

    Fix the if-else logic, so the hooks will work correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build-*-bundle gets stuck at nativescript-unit-test-runner hook in NS 3.2
2 participants