@powersync/service-core 0.0.0-dev-20250122110924 → 0.0.0-dev-20250227082606

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.
Files changed (193) hide show
  1. package/CHANGELOG.md +84 -9
  2. package/dist/api/RouteAPI.d.ts +9 -1
  3. package/dist/api/diagnostics.js +107 -169
  4. package/dist/api/diagnostics.js.map +1 -1
  5. package/dist/auth/CachedKeyCollector.js +26 -25
  6. package/dist/auth/CachedKeyCollector.js.map +1 -1
  7. package/dist/auth/CompoundKeyCollector.js +1 -0
  8. package/dist/auth/CompoundKeyCollector.js.map +1 -1
  9. package/dist/auth/KeySpec.js +3 -0
  10. package/dist/auth/KeySpec.js.map +1 -1
  11. package/dist/auth/KeyStore.js +4 -0
  12. package/dist/auth/KeyStore.js.map +1 -1
  13. package/dist/auth/LeakyBucket.js +5 -0
  14. package/dist/auth/LeakyBucket.js.map +1 -1
  15. package/dist/auth/RemoteJWKSCollector.js +4 -1
  16. package/dist/auth/RemoteJWKSCollector.js.map +1 -1
  17. package/dist/auth/StaticKeyCollector.js +1 -0
  18. package/dist/auth/StaticKeyCollector.js.map +1 -1
  19. package/dist/auth/StaticSupabaseKeyCollector.js +1 -0
  20. package/dist/auth/StaticSupabaseKeyCollector.js.map +1 -1
  21. package/dist/entry/commands/compact-action.js +10 -73
  22. package/dist/entry/commands/compact-action.js.map +1 -1
  23. package/dist/metrics/Metrics.js +35 -1
  24. package/dist/metrics/Metrics.js.map +1 -1
  25. package/dist/modules/AbstractModule.d.ts +1 -1
  26. package/dist/modules/AbstractModule.js +2 -0
  27. package/dist/modules/AbstractModule.js.map +1 -1
  28. package/dist/modules/ModuleManager.js +1 -3
  29. package/dist/modules/ModuleManager.js.map +1 -1
  30. package/dist/replication/AbstractReplicationJob.js +4 -2
  31. package/dist/replication/AbstractReplicationJob.js.map +1 -1
  32. package/dist/replication/AbstractReplicator.js +26 -88
  33. package/dist/replication/AbstractReplicator.js.map +1 -1
  34. package/dist/replication/ReplicationEngine.js +1 -3
  35. package/dist/replication/ReplicationEngine.js.map +1 -1
  36. package/dist/replication/ReplicationModule.js +3 -0
  37. package/dist/replication/ReplicationModule.js.map +1 -1
  38. package/dist/routes/RouterEngine.js +8 -0
  39. package/dist/routes/RouterEngine.js.map +1 -1
  40. package/dist/routes/configure-fastify.d.ts +3 -3
  41. package/dist/routes/endpoints/admin.d.ts +6 -6
  42. package/dist/routes/endpoints/admin.js +4 -1
  43. package/dist/routes/endpoints/admin.js.map +1 -1
  44. package/dist/routes/endpoints/checkpointing.js +17 -86
  45. package/dist/routes/endpoints/checkpointing.js.map +1 -1
  46. package/dist/routes/endpoints/socket-route.js +7 -6
  47. package/dist/routes/endpoints/socket-route.js.map +1 -1
  48. package/dist/routes/endpoints/sync-rules.js +7 -2
  49. package/dist/routes/endpoints/sync-rules.js.map +1 -1
  50. package/dist/routes/endpoints/sync-stream.js +7 -6
  51. package/dist/routes/endpoints/sync-stream.js.map +1 -1
  52. package/dist/runner/teardown.js +5 -67
  53. package/dist/runner/teardown.js.map +1 -1
  54. package/dist/storage/BucketStorage.d.ts +8 -414
  55. package/dist/storage/BucketStorage.js +9 -7
  56. package/dist/storage/BucketStorage.js.map +1 -1
  57. package/dist/storage/BucketStorageBatch.d.ts +130 -0
  58. package/dist/storage/BucketStorageBatch.js +10 -0
  59. package/dist/storage/BucketStorageBatch.js.map +1 -0
  60. package/dist/storage/BucketStorageFactory.d.ts +145 -0
  61. package/dist/storage/BucketStorageFactory.js +2 -0
  62. package/dist/storage/BucketStorageFactory.js.map +1 -0
  63. package/dist/storage/ChecksumCache.js +12 -7
  64. package/dist/storage/ChecksumCache.js.map +1 -1
  65. package/dist/storage/PersistedSyncRulesContent.d.ts +20 -0
  66. package/dist/storage/PersistedSyncRulesContent.js +2 -0
  67. package/dist/storage/PersistedSyncRulesContent.js.map +1 -0
  68. package/dist/storage/ReplicationEventPayload.d.ts +1 -1
  69. package/dist/storage/ReplicationLock.d.ts +4 -0
  70. package/dist/storage/ReplicationLock.js +2 -0
  71. package/dist/storage/ReplicationLock.js.map +1 -0
  72. package/dist/storage/SourceEntity.d.ts +6 -2
  73. package/dist/storage/SourceTable.d.ts +2 -2
  74. package/dist/storage/SourceTable.js +32 -25
  75. package/dist/storage/SourceTable.js.map +1 -1
  76. package/dist/storage/StorageEngine.d.ts +4 -4
  77. package/dist/storage/StorageEngine.js +6 -5
  78. package/dist/storage/StorageEngine.js.map +1 -1
  79. package/dist/storage/StorageProvider.d.ts +4 -1
  80. package/dist/storage/SyncRulesBucketStorage.d.ts +207 -0
  81. package/dist/storage/SyncRulesBucketStorage.js +7 -0
  82. package/dist/storage/SyncRulesBucketStorage.js.map +1 -0
  83. package/dist/storage/bson.d.ts +19 -6
  84. package/dist/storage/bson.js +18 -2
  85. package/dist/storage/bson.js.map +1 -1
  86. package/dist/storage/storage-index.d.ts +5 -0
  87. package/dist/storage/storage-index.js +5 -0
  88. package/dist/storage/storage-index.js.map +1 -1
  89. package/dist/sync/BroadcastIterable.js +4 -3
  90. package/dist/sync/BroadcastIterable.js.map +1 -1
  91. package/dist/sync/BucketChecksumState.d.ts +95 -0
  92. package/dist/sync/BucketChecksumState.js +321 -0
  93. package/dist/sync/BucketChecksumState.js.map +1 -0
  94. package/dist/sync/LastValueSink.js +2 -0
  95. package/dist/sync/LastValueSink.js.map +1 -1
  96. package/dist/sync/RequestTracker.js +2 -4
  97. package/dist/sync/RequestTracker.js.map +1 -1
  98. package/dist/sync/SyncContext.d.ts +17 -0
  99. package/dist/sync/SyncContext.js +23 -0
  100. package/dist/sync/SyncContext.js.map +1 -0
  101. package/dist/sync/merge.js +4 -0
  102. package/dist/sync/merge.js.map +1 -1
  103. package/dist/sync/sync-index.d.ts +2 -0
  104. package/dist/sync/sync-index.js +2 -0
  105. package/dist/sync/sync-index.js.map +1 -1
  106. package/dist/sync/sync.d.ts +10 -4
  107. package/dist/sync/sync.js +143 -149
  108. package/dist/sync/sync.js.map +1 -1
  109. package/dist/sync/util.d.ts +9 -0
  110. package/dist/sync/util.js +46 -2
  111. package/dist/sync/util.js.map +1 -1
  112. package/dist/system/ServiceContext.d.ts +3 -0
  113. package/dist/system/ServiceContext.js +10 -0
  114. package/dist/system/ServiceContext.js.map +1 -1
  115. package/dist/util/Mutex.js +5 -0
  116. package/dist/util/Mutex.js.map +1 -1
  117. package/dist/util/checkpointing.d.ts +13 -0
  118. package/dist/util/checkpointing.js +29 -0
  119. package/dist/util/checkpointing.js.map +1 -0
  120. package/dist/util/config/compound-config-collector.js +16 -2
  121. package/dist/util/config/compound-config-collector.js.map +1 -1
  122. package/dist/util/config/defaults.d.ts +5 -0
  123. package/dist/util/config/defaults.js +6 -0
  124. package/dist/util/config/defaults.js.map +1 -0
  125. package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js +1 -0
  126. package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js.map +1 -1
  127. package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js +1 -0
  128. package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js.map +1 -1
  129. package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js +1 -0
  130. package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js.map +1 -1
  131. package/dist/util/config/sync-rules/sync-rules-provider.d.ts +2 -0
  132. package/dist/util/config/sync-rules/sync-rules-provider.js +4 -0
  133. package/dist/util/config/sync-rules/sync-rules-provider.js.map +1 -1
  134. package/dist/util/config/types.d.ts +8 -2
  135. package/dist/util/config/types.js.map +1 -1
  136. package/dist/util/memory-tracking.js +1 -1
  137. package/dist/util/memory-tracking.js.map +1 -1
  138. package/dist/util/protocol-types.d.ts +13 -4
  139. package/dist/util/util-index.d.ts +1 -0
  140. package/dist/util/util-index.js +1 -0
  141. package/dist/util/util-index.js.map +1 -1
  142. package/dist/util/utils.d.ts +0 -1
  143. package/dist/util/utils.js +0 -9
  144. package/dist/util/utils.js.map +1 -1
  145. package/package.json +6 -6
  146. package/src/api/RouteAPI.ts +11 -1
  147. package/src/api/diagnostics.ts +1 -1
  148. package/src/entry/commands/compact-action.ts +2 -3
  149. package/src/modules/AbstractModule.ts +1 -1
  150. package/src/replication/AbstractReplicator.ts +16 -15
  151. package/src/routes/RouterEngine.ts +1 -0
  152. package/src/routes/endpoints/admin.ts +4 -1
  153. package/src/routes/endpoints/checkpointing.ts +11 -22
  154. package/src/routes/endpoints/socket-route.ts +9 -6
  155. package/src/routes/endpoints/sync-rules.ts +7 -2
  156. package/src/routes/endpoints/sync-stream.ts +10 -6
  157. package/src/runner/teardown.ts +1 -1
  158. package/src/storage/BucketStorage.ts +8 -515
  159. package/src/storage/BucketStorageBatch.ts +158 -0
  160. package/src/storage/BucketStorageFactory.ts +166 -0
  161. package/src/storage/ChecksumCache.ts +1 -0
  162. package/src/storage/PersistedSyncRulesContent.ts +26 -0
  163. package/src/storage/ReplicationEventPayload.ts +1 -1
  164. package/src/storage/ReplicationLock.ts +5 -0
  165. package/src/storage/SourceEntity.ts +6 -2
  166. package/src/storage/SourceTable.ts +1 -1
  167. package/src/storage/StorageEngine.ts +4 -4
  168. package/src/storage/StorageProvider.ts +4 -1
  169. package/src/storage/SyncRulesBucketStorage.ts +265 -0
  170. package/src/storage/bson.ts +31 -11
  171. package/src/storage/storage-index.ts +5 -0
  172. package/src/sync/BucketChecksumState.ts +418 -0
  173. package/src/sync/SyncContext.ts +36 -0
  174. package/src/sync/sync-index.ts +2 -0
  175. package/src/sync/sync.ts +199 -177
  176. package/src/sync/util.ts +54 -0
  177. package/src/system/ServiceContext.ts +9 -0
  178. package/src/util/checkpointing.ts +41 -0
  179. package/src/util/config/compound-config-collector.ts +26 -2
  180. package/src/util/config/defaults.ts +5 -0
  181. package/src/util/config/sync-rules/impl/base64-sync-rules-collector.ts +1 -0
  182. package/src/util/config/sync-rules/impl/filesystem-sync-rules-collector.ts +1 -0
  183. package/src/util/config/sync-rules/impl/inline-sync-rules-collector.ts +1 -0
  184. package/src/util/config/sync-rules/sync-rules-provider.ts +6 -0
  185. package/src/util/config/types.ts +9 -2
  186. package/src/util/memory-tracking.ts +2 -2
  187. package/src/util/protocol-types.ts +16 -4
  188. package/src/util/util-index.ts +1 -0
  189. package/src/util/utils.ts +0 -10
  190. package/test/src/auth.test.ts +5 -5
  191. package/test/src/sync/BucketChecksumState.test.ts +580 -0
  192. package/test/src/sync/util.test.ts +34 -0
  193. package/tsconfig.tsbuildinfo +1 -1
@@ -10,6 +10,13 @@ import { FileSystemSyncRulesCollector } from './sync-rules/impl/filesystem-sync-
10
10
  import { InlineSyncRulesCollector } from './sync-rules/impl/inline-sync-rules-collector.js';
11
11
  import { SyncRulesCollector } from './sync-rules/sync-collector.js';
12
12
  import { ResolvedPowerSyncConfig, RunnerConfig, SyncRulesConfig } from './types.js';
13
+ import {
14
+ DEFAULT_MAX_BUCKETS_PER_CONNECTION,
15
+ DEFAULT_MAX_CONCURRENT_CONNECTIONS,
16
+ DEFAULT_MAX_DATA_FETCH_CONCURRENCY,
17
+ DEFAULT_MAX_PARAMETER_QUERY_RESULTS,
18
+ DEFAULT_MAX_POOL_SIZE
19
+ } from './defaults.js';
13
20
 
14
21
  export type CompoundConfigCollectorOptions = {
15
22
  /**
@@ -124,7 +131,12 @@ export class CompoundConfigCollector {
124
131
  let config: ResolvedPowerSyncConfig = {
125
132
  base_config: baseConfig,
126
133
  connections: baseConfig.replication?.connections || [],
127
- storage: baseConfig.storage,
134
+ storage: {
135
+ ...baseConfig.storage,
136
+ parameters: {
137
+ max_pool_size: baseConfig.storage?.parameters?.max_pool_size ?? DEFAULT_MAX_POOL_SIZE
138
+ }
139
+ },
128
140
  client_keystore: keyStore,
129
141
  // Dev tokens only use the static keys, no external key sources
130
142
  // We may restrict this even further to only the powersync-dev key.
@@ -146,6 +158,17 @@ export class CompoundConfigCollector {
146
158
  internal_service_endpoint:
147
159
  baseConfig.telemetry?.internal_service_endpoint ?? 'https://pulse.journeyapps.com/v1/metrics'
148
160
  },
161
+ api_parameters: {
162
+ max_buckets_per_connection:
163
+ baseConfig.api?.parameters?.max_buckets_per_connection ?? DEFAULT_MAX_BUCKETS_PER_CONNECTION,
164
+
165
+ max_parameter_query_results:
166
+ baseConfig.api?.parameters?.max_parameter_query_results ?? DEFAULT_MAX_PARAMETER_QUERY_RESULTS,
167
+ max_concurrent_connections:
168
+ baseConfig.api?.parameters?.max_concurrent_connections ?? DEFAULT_MAX_CONCURRENT_CONNECTIONS,
169
+ max_data_fetch_concurrency:
170
+ baseConfig.api?.parameters?.max_data_fetch_concurrency ?? DEFAULT_MAX_DATA_FETCH_CONCURRENCY
171
+ },
149
172
  // TODO maybe move this out of the connection or something
150
173
  // slot_name_prefix: connections[0]?.slot_name_prefix ?? 'powersync_'
151
174
  slot_name_prefix: 'powersync_',
@@ -196,7 +219,8 @@ export class CompoundConfigCollector {
196
219
  }
197
220
  }
198
221
  return {
199
- present: false
222
+ present: false,
223
+ exit_on_error: true
200
224
  };
201
225
  }
202
226
  }
@@ -0,0 +1,5 @@
1
+ export const DEFAULT_MAX_POOL_SIZE = 8;
2
+ export const DEFAULT_MAX_CONCURRENT_CONNECTIONS = 200;
3
+ export const DEFAULT_MAX_DATA_FETCH_CONCURRENCY = 10;
4
+ export const DEFAULT_MAX_BUCKETS_PER_CONNECTION = 1000;
5
+ export const DEFAULT_MAX_PARAMETER_QUERY_RESULTS = 1000;
@@ -15,6 +15,7 @@ export class Base64SyncRulesCollector extends SyncRulesCollector {
15
15
 
16
16
  return {
17
17
  present: true,
18
+ exit_on_error: baseConfig.sync_rules?.exit_on_error ?? true,
18
19
  content: Buffer.from(sync_rules_base64, 'base64').toString()
19
20
  };
20
21
  }
@@ -20,6 +20,7 @@ export class FileSystemSyncRulesCollector extends SyncRulesCollector {
20
20
  // Only persist the path here, and load on demand using `loadSyncRules()`.
21
21
  return {
22
22
  present: true,
23
+ exit_on_error: baseConfig.sync_rules?.exit_on_error ?? true,
23
24
  path: config_path ? path.resolve(path.dirname(config_path), sync_path) : sync_path
24
25
  };
25
26
  }
@@ -15,6 +15,7 @@ export class InlineSyncRulesCollector extends SyncRulesCollector {
15
15
 
16
16
  return {
17
17
  present: true,
18
+ exit_on_error: true,
18
19
  ...baseConfig.sync_rules
19
20
  };
20
21
  }
@@ -3,6 +3,8 @@ import fs from 'fs/promises';
3
3
 
4
4
  export interface SyncRulesProvider {
5
5
  get(): Promise<string | undefined>;
6
+
7
+ readonly exitOnError: boolean;
6
8
  }
7
9
 
8
10
  export class ConfigurationFileSyncRulesProvider implements SyncRulesProvider {
@@ -15,4 +17,8 @@ export class ConfigurationFileSyncRulesProvider implements SyncRulesProvider {
15
17
  return await fs.readFile(this.config.path, 'utf-8');
16
18
  }
17
19
  }
20
+
21
+ get exitOnError() {
22
+ return this.config.exit_on_error;
23
+ }
18
24
  }
@@ -1,5 +1,4 @@
1
1
  import { configFile } from '@powersync/service-types';
2
- import { PowerSyncConfig } from '@powersync/service-types/src/config/PowerSyncConfig.js';
3
2
  import { CompoundKeyCollector } from '../../auth/CompoundKeyCollector.js';
4
3
  import { KeySpec } from '../../auth/KeySpec.js';
5
4
  import { KeyStore } from '../../auth/KeyStore.js';
@@ -26,10 +25,11 @@ export type SyncRulesConfig = {
26
25
  present: boolean;
27
26
  content?: string;
28
27
  path?: string;
28
+ exit_on_error: boolean;
29
29
  };
30
30
 
31
31
  export type ResolvedPowerSyncConfig = {
32
- base_config: PowerSyncConfig;
32
+ base_config: configFile.PowerSyncConfig;
33
33
  connections?: configFile.GenericDataSourceConfig[];
34
34
  storage: configFile.GenericStorageConfig;
35
35
  dev: {
@@ -59,6 +59,13 @@ export type ResolvedPowerSyncConfig = {
59
59
  internal_service_endpoint: string;
60
60
  };
61
61
 
62
+ api_parameters: {
63
+ max_concurrent_connections: number;
64
+ max_data_fetch_concurrency: number;
65
+ max_buckets_per_connection: number;
66
+ max_parameter_query_results: number;
67
+ };
68
+
62
69
  /** Prefix for postgres replication slot names. May eventually be connection-specific. */
63
70
  slot_name_prefix: string;
64
71
  parameters: Record<string, number | string | boolean | null>;
@@ -25,8 +25,8 @@ export function trackMemoryUsage() {
25
25
  for (let key of Object.keys(bufferMemory)) {
26
26
  const typedKey = key as keyof typeof bufferMemory;
27
27
  const originalFunction = Buffer[typedKey] as (...args: any[]) => Buffer;
28
- Buffer[typedKey] = function (...args: any[]) {
29
- const buffer = originalFunction.apply(this, args);
28
+ Buffer[typedKey] = function <TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>(...args: any[]) {
29
+ const buffer = originalFunction.apply(this, args) as Buffer<TArrayBuffer>;
30
30
  bufferMemory[typedKey] += buffer.byteLength;
31
31
  bufferRegistry.register(buffer, [typedKey, buffer.byteLength]);
32
32
  return buffer;
@@ -1,5 +1,5 @@
1
1
  import * as t from 'ts-codec';
2
- import { SqliteJsonValue } from '@powersync/service-sync-rules';
2
+ import { BucketDescription, BucketPriority, SqliteJsonValue } from '@powersync/service-sync-rules';
3
3
 
4
4
  export const BucketRequest = t.object({
5
5
  name: t.string,
@@ -59,7 +59,7 @@ export interface StreamingSyncCheckpointDiff {
59
59
  checkpoint_diff: {
60
60
  last_op_id: OpId;
61
61
  write_checkpoint?: OpId;
62
- updated_buckets: BucketChecksum[];
62
+ updated_buckets: BucketChecksumWithDescription[];
63
63
  removed_buckets: string[];
64
64
  };
65
65
  }
@@ -74,13 +74,23 @@ export interface StreamingSyncCheckpointComplete {
74
74
  };
75
75
  }
76
76
 
77
- export interface StreamingSyncKeepalive {}
77
+ export interface StreamingSyncCheckpointPartiallyComplete {
78
+ partial_checkpoint_complete: {
79
+ last_op_id: OpId;
80
+ priority: BucketPriority;
81
+ };
82
+ }
83
+
84
+ export interface StreamingSyncKeepalive {
85
+ token_expires_in: number;
86
+ }
78
87
 
79
88
  export type StreamingSyncLine =
80
89
  | StreamingSyncData
81
90
  | StreamingSyncCheckpoint
82
91
  | StreamingSyncCheckpointDiff
83
92
  | StreamingSyncCheckpointComplete
93
+ | StreamingSyncCheckpointPartiallyComplete
84
94
  | StreamingSyncKeepalive;
85
95
 
86
96
  /**
@@ -91,7 +101,7 @@ export type OpId = string;
91
101
  export interface Checkpoint {
92
102
  last_op_id: OpId;
93
103
  write_checkpoint?: OpId;
94
- buckets: BucketChecksum[];
104
+ buckets: BucketChecksumWithDescription[];
95
105
  }
96
106
 
97
107
  export interface BucketState {
@@ -142,3 +152,5 @@ export interface BucketChecksum {
142
152
  */
143
153
  count: number;
144
154
  }
155
+
156
+ export interface BucketChecksumWithDescription extends BucketChecksum, BucketDescription {}
@@ -5,6 +5,7 @@ export * from './Mutex.js';
5
5
  export * from './protocol-types.js';
6
6
  export * from './secs.js';
7
7
  export * from './utils.js';
8
+ export * from './checkpointing.js';
8
9
 
9
10
  export * from './config.js';
10
11
  export * from './config/compound-config-collector.js';
package/src/util/utils.ts CHANGED
@@ -145,16 +145,6 @@ export function isCompleteRow(storeData: boolean, row: sync_rules.ToastableSqlit
145
145
  return !hasToastedValues(row);
146
146
  }
147
147
 
148
- export function checkpointUserId(user_id: string | undefined, client_id: string | undefined) {
149
- if (user_id == null) {
150
- throw new Error('user_id is required');
151
- }
152
- if (client_id == null) {
153
- return user_id;
154
- }
155
- return `${user_id}/${client_id}`;
156
- }
157
-
158
148
  /**
159
149
  * Reduce a bucket to the final state as stored on the client.
160
150
  *
@@ -274,7 +274,7 @@ describe('JWT Auth', () => {
274
274
  ).rejects.toThrow('Token must expire in a maximum of');
275
275
  });
276
276
 
277
- test('http', async () => {
277
+ test('http', { timeout: 20_000 }, async () => {
278
278
  // Not ideal to rely on an external endpoint for tests, but it is good to test that this
279
279
  // one actually works.
280
280
  const remote = new RemoteJWKSCollector(
@@ -290,9 +290,9 @@ describe('JWT Auth', () => {
290
290
  reject_ip_ranges: ['local']
291
291
  }
292
292
  });
293
- expect(invalid.getKeys()).rejects.toThrow('IPs in this range are not supported');
293
+ await expect(invalid.getKeys()).rejects.toThrow('IPs in this range are not supported');
294
294
 
295
- // IPS throw an error immediately
295
+ // IPs throw an error immediately
296
296
  expect(
297
297
  () =>
298
298
  new RemoteJWKSCollector('https://127.0.0.1/.well-known/jwks.json', {
@@ -315,11 +315,11 @@ describe('JWT Auth', () => {
315
315
 
316
316
  const invalid = new RemoteJWKSCollector('https://127.0.0.1/.well-known/jwks.json');
317
317
  // Should try and fetch
318
- expect(invalid.getKeys()).rejects.toThrow();
318
+ await expect(invalid.getKeys()).rejects.toThrow();
319
319
 
320
320
  const invalid2 = new RemoteJWKSCollector('https://localhost/.well-known/jwks.json');
321
321
  // Should try and fetch
322
- expect(invalid2.getKeys()).rejects.toThrow();
322
+ await expect(invalid2.getKeys()).rejects.toThrow();
323
323
  });
324
324
 
325
325
  test('caching', async () => {