spice-js 2.7.36 → 2.7.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -189,6 +189,10 @@ class Spice {
189
189
  return spice;
190
190
  } catch (e) {
191
191
  console.log(e.stack);
192
+ // A failed init leaves no usable application (no config, no database,
193
+ // no routes). Surface it so the host process can exit instead of
194
+ // listening on a port with nothing behind it.
195
+ throw e;
192
196
  }
193
197
  })();
194
198
  }
@@ -25,11 +25,22 @@ function _load() {
25
25
  console.log('APP Bootstrap directory', app_bootstrap_path); */
26
26
  console.log("Loading Ordered Files", ordered_modules);
27
27
  for (var file of ordered_modules) {
28
- var mod = require(_path.default.join(bootstrap_path, file));
29
- if (_lodash.default.isFunction(mod)) {
30
- yield mod();
28
+ try {
29
+ var mod = require(_path.default.join(bootstrap_path, file));
30
+ if (_lodash.default.isFunction(mod)) {
31
+ yield mod();
32
+ }
33
+ console.log("loaded", file);
34
+ } catch (e) {
35
+ // The ordered modules are the foundation: database, models, logger.
36
+ // Nothing loaded after them can work without them, so swallowing the
37
+ // error here produced a half-booted process (no routes, no models,
38
+ // no retry) that still looked alive. Mark it and let init() rethrow
39
+ // so the host application can exit and be restarted.
40
+ console.log("Failed to load core module \"" + file + "\"");
41
+ e.spice_core_module = file;
42
+ throw e;
31
43
  }
32
- console.log("loaded", file);
33
44
  }
34
45
  var paths = [bootstrap_path, app_bootstrap_path];
35
46
  for (var loadder_path of paths) {
@@ -52,6 +63,9 @@ function _load() {
52
63
  }
53
64
  } catch (e) {
54
65
  console.log(e.stack);
66
+ if (e.spice_core_module) {
67
+ throw e;
68
+ }
55
69
  }
56
70
  });
57
71
  return _load.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.7.36",
3
+ "version": "2.7.38",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -166,6 +166,10 @@ export default class Spice {
166
166
  return spice;
167
167
  } catch (e) {
168
168
  console.log(e.stack);
169
+ // A failed init leaves no usable application (no config, no database,
170
+ // no routes). Surface it so the host process can exit instead of
171
+ // listening on a port with nothing behind it.
172
+ throw e;
169
173
  }
170
174
  }
171
175
  }
@@ -26,11 +26,22 @@ export async function load() {
26
26
  console.log('APP Bootstrap directory', app_bootstrap_path); */
27
27
  console.log("Loading Ordered Files", ordered_modules);
28
28
  for (let file of ordered_modules) {
29
- let mod = require(path.join(bootstrap_path, file));
30
- if (_.isFunction(mod)) {
31
- await mod();
29
+ try {
30
+ let mod = require(path.join(bootstrap_path, file));
31
+ if (_.isFunction(mod)) {
32
+ await mod();
33
+ }
34
+ console.log("loaded", file);
35
+ } catch (e) {
36
+ // The ordered modules are the foundation: database, models, logger.
37
+ // Nothing loaded after them can work without them, so swallowing the
38
+ // error here produced a half-booted process (no routes, no models,
39
+ // no retry) that still looked alive. Mark it and let init() rethrow
40
+ // so the host application can exit and be restarted.
41
+ console.log(`Failed to load core module "${file}"`);
42
+ e.spice_core_module = file;
43
+ throw e;
32
44
  }
33
- console.log("loaded", file);
34
45
  }
35
46
 
36
47
  let paths = [bootstrap_path, app_bootstrap_path];
@@ -60,6 +71,9 @@ export async function load() {
60
71
  }
61
72
  } catch (e) {
62
73
  console.log(e.stack);
74
+ if (e.spice_core_module) {
75
+ throw e;
76
+ }
63
77
  }
64
78
  }
65
79
  //load();