Skip to content

Racing condition for copy of constant file when transpiling client code #1830

Closed
@Koslun

Description

Item Version
generator-angular-fullstack 3.6.1
Node 4.4.2
npm 3.8.7
Operating System Ubuntu 15.10
MongoDB 3.0
Item Answer
Transpiler TypeScript
Markup HTML
CSS SCSS
Router ngRoute
Build Tool Gulp
Client Tests Jasmine
DB MongoDB
Auth Y
Bootstrap Y
BootstrapUI Y
SocketIO Y

Used the above configuration but think this should apply for all Gulp and TypeScript flavors.

Using the above configuration all tests pass but running gulp serve gives you an error indicating that the appName.constant.js file is missing. Error can be observed when trying to access the served page outputting the following to the developer console:

Uncaught Error: [$injector:modulerr] Failed to instantiate module karmaProjectApp due to:
Error: [$injector:modulerr] Failed to instantiate module karmaProjectApp.auth due to:
Error: [$injector:modulerr] Failed to instantiate module karmaProjectApp.constants due to:
Error: [$injector:nomod] Module 'karmaProjectApp.constants' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.5/$injector/nomod?p0=karmaProjectApp.constants
//and much more

Underlying problem is the following:
The task copy:constant copies the constant file. This however relies on that the constant file has been created by the task constant. Where the only task that uses copy:constant is the task transpile:client, which loads task constant in parallel with copy:constant, particularly being written before in the parallel order. A racing condition is thus present where constant needs to finish faster than copy:constant can begin.

Think the constant task was either loaded faster or was somehow run ahead of the transpile:client task in some previous commit. Either way the constant task should be a dependency of task copy:constant.

Creating PR to fix shortly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions