velocious 1.0.22 → 1.0.23

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.22",
6
+ "version": "1.0.23",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "test": "jasmine",
@@ -5,29 +5,30 @@ import useEnvSense from "env-sense/src/use-env-sense.js"
5
5
  import Configuration from "../configuration.js"
6
6
  import restArgsError from "../utils/rest-args-error.js"
7
7
 
8
- const shared = {
9
- loaded: false
10
- }
11
-
12
8
  const loadMigrations = function loadMigrations({migrationsRequireContext, ...restArgs}) {
9
+ const instance = React.useMemo(() => ({running: false}), [])
13
10
  const {isServer} = useEnvSense()
14
- const [loaded, setLoaded] = React.useState(shared.loaded)
11
+ const [loaded, setLoaded] = React.useState(false)
15
12
 
16
13
  const loadDatabase = React.useCallback(async () => {
17
- await Configuration.current().getDatabasePool().withConnection(async () => {
18
- const databaseMigrateFromRequireContext = new DatabaseMigrateFromRequireContext()
14
+ instance.running = true
19
15
 
20
- await databaseMigrateFromRequireContext.execute(migrationsRequireContext)
21
- })
16
+ try {
17
+ await Configuration.current().getDatabasePool().withConnection(async () => {
18
+ const databaseMigrateFromRequireContext = new DatabaseMigrateFromRequireContext()
22
19
 
23
- await Configuration.current().initialize()
20
+ await databaseMigrateFromRequireContext.execute(migrationsRequireContext)
21
+ })
24
22
 
25
- shared.loaded = true
26
- setLoaded(true)
23
+ await Configuration.current().initialize()
24
+ setLoaded(true)
25
+ } finally {
26
+ instance.running = false
27
+ }
27
28
  }, [])
28
29
 
29
30
  React.useMemo(() => {
30
- if (!loaded && !isServer) {
31
+ if (!loaded && !isServer && !instance.running) {
31
32
  loadDatabase()
32
33
  }
33
34
  }, [loaded])