[ 
https://issues.apache.org/jira/browse/CB-9278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14649140#comment-14649140
 ] 

ASF GitHub Bot commented on CB-9278:
------------------------------------

Github user TimBarham commented on the pull request:

    https://github.com/apache/cordova-lib/pull/266#issuecomment-126670748
  
    Made this comment offline, but decided it should be included here too... I 
don't think this is the right fix - I think a more general approach would serve 
use better in the long run. There may be other scenarios (now or in the future) 
where we end up calling into `npm-helper` with multiple `npm` actions that 
aren't triggered sequentially. I think it would be better/safer to update 
`npm-helper` to handle that properly, rather than having to modify existing 
cases (or remember to always do it sequentially in the future).
    
    Since `npm-helper`'s `loadWithSettingsThenRestore()` method ensures we 
always restore (even if something fails), if subsequent calls come in before 
we've restored from a previous call (which is what currently triggers the 
error), we can queue up those subsequent calls and process each them (and hence 
fulfill the corresponding promise) only once we've restored for all the calls 
that preceded it.
    
    This shouldn't be too hard to code up, and provides us with a more robust 
solution at the root of the problem.


> Restoring multiple platforms fails
> ----------------------------------
>
>                 Key: CB-9278
>                 URL: https://issues.apache.org/jira/browse/CB-9278
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaLib
>    Affects Versions: Master
>         Environment: OS X
>            Reporter: Dmitry Blotsky
>            Assignee: Omar Mefire
>              Labels: cordova-lib, platform, restore, save
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Steps to reproduce:
> 1. Create a blank app: {{cordova create test com.app.test test}}
> 2. Add and save a platform: {{cordova platform add --save ios}}
> 3. Add and save another platform: {{cordova platform add --save android}}
> 4. Remove the platforms: {{cordova platform remove android ios}}
> 5. Try to restore platforms automatically: {{cordova prepare}}
> Expected: both platforms installed and prepared
> Actual:
> {noformat}
> Error: Trying to initialize npm when settings have not been restored from a 
> previous initialization.
> {noformat}
> Running {{cordova prepare}} again fixes the issue.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to