Skip to content

Commit

Permalink
feat: make sure to shutdown the current failed extension
Browse files Browse the repository at this point in the history
  • Loading branch information
juneil committed May 9, 2018
1 parent 6658dda commit 988d6e5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/core/hapiness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ export class Hapiness {
null,
_ => {
this.logger.debug(`bootstrap error catched [${_.message}], shutting down extension ...`);

this.shutdown()
this
.shutdown()
.subscribe(
() => {},
err => this.logger.debug(`(2) bootstrap error catched [${err.message}], shutting down extension ...`)
() => reject(_),
err => {
this.logger.debug(`bootstrap error catched [${err.message}], shutting down extension ...`);
reject(err);
process.exit(1);
}
);

reject(_);
},
() => resolve()
);
Expand Down Expand Up @@ -129,7 +131,7 @@ export class Hapiness {
return Observable
.from([].concat(extensions).filter(_ => !!_))
.map(_ => this.toExtensionWithConfig(_))
.flatMap(_ => this
.concatMap(_ => this
.loadExtention(_, moduleResolved)
.timeout(options.extensionTimeout || this.defaultTimeout)
.catch(err => Observable.throw(extensionError(err, _.token.name)))
Expand Down Expand Up @@ -265,6 +267,12 @@ export class Hapiness {
instance,
[ module, extension.config ]
)
.catch(_ => {
this.extensions = [].concat(this.extensions, instance);
return this
.shutdown()
.flatMap(() => Observable.throw(_));
})
)
.do(_ => this.extensions = []
.concat(this.extensions, _)
Expand Down

0 comments on commit 988d6e5

Please sign in to comment.