Skip to content

Commit b951ab4

Browse files
committed
fix(tests): destroy s3 during close and close file
1 parent 9ffd44f commit b951ab4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

typegate/src/typegate/artifacts/shared.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,26 @@ export class SharedArtifactStore extends ArtifactStore {
104104
// Read file content into a Uint8Array
105105
const fileContent = await readAll(readFile);
106106
console.log(`Persisting artifact to S3`);
107-
await this.#s3.putObject({
107+
const _ = await this.#s3.putObject({
108108
Bucket: this.#syncConfig.s3Bucket,
109109
Body: fileContent,
110110
Key: resolveS3Key(hash),
111111
});
112+
readFile.close();
112113

113114
return hash;
114115
}
115116

116117
override async delete(hash: string): Promise<void> {
117-
await this.#s3.deleteObject({
118+
const _ = await this.#s3.deleteObject({
118119
Bucket: this.#syncConfig.s3Bucket,
119120
Key: resolveS3Key(hash),
120121
});
121122
}
122123

123124
override async has(hash: string): Promise<boolean> {
124125
try {
125-
await this.#s3.headObject({
126+
const _ = await this.#s3.headObject({
126127
Bucket: this.#syncConfig.s3Bucket,
127128
Key: resolveS3Key(hash),
128129
});
@@ -213,7 +214,7 @@ export class SharedArtifactStore extends ArtifactStore {
213214
}
214215

215216
async #addUrlToRedis(url: string, value: string, expirationDuration: number) {
216-
await this.#uploadUrls.redisClient.eval(
217+
const _ = await this.#uploadUrls.redisClient.eval(
217218
setCmd,
218219
[resolveRedisUrlKey(url)],
219220
[value, expirationDuration],
@@ -239,14 +240,15 @@ export class SharedArtifactStore extends ArtifactStore {
239240
}
240241

241242
async #removeFromRedis(url: string) {
242-
await this.#uploadUrls.redisClient.eval(
243+
const _ = await this.#uploadUrls.redisClient.eval(
243244
"redis.call('DEL', KEYS[1])",
244245
[resolveRedisUrlKey(url)],
245246
[],
246247
);
247248
}
248249

249250
override async close(): Promise<void> {
251+
this.#s3.destroy();
250252
await deinitRemoteUploadUrlStore(this.#uploadUrls);
251253
return Promise.resolve(void null);
252254
}

0 commit comments

Comments
 (0)