Skip to content

Commit

Permalink
Don't modify exports
Browse files Browse the repository at this point in the history
  • Loading branch information
ejscribner committed Sep 3, 2024
1 parent 6f56816 commit bfae1b2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ottoman/ottoman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export type OttomanEvents = 'IndexOnline';
* Store default connection.
*/
export let __ottoman: Ottoman;
export const __ottomanInstances: Ottoman[] = [];
export let __ottomanInstances: Ottoman[] = [];

export class Ottoman {
private n1qlIndexes: Record<string, { fields: string[]; modelName: string }> = {};
Expand Down Expand Up @@ -376,16 +376,15 @@ export class Ottoman {
* connection.close().then(() => console.log('connection closed'));
* ```
*/
async close() {
console.log('Closing: ', this.id, exports.__ottoman ? exports.__ottoman.id : '____');
async close(): Promise<void> {
console.log('Closing: ', this.id, __ottoman ? __ottoman.id : '____');
if (this.cluster) {
exports.__ottomanInstances = exports.__ottomanInstances.filter((instance) => instance.id !== this.id);
if (exports.__ottoman?.id === this.id) {
console.log(exports.__ottoman.id, '__ottoman -> undefined');
exports.__ottoman = undefined;
__ottomanInstances = __ottomanInstances.filter((instance) => instance.id !== this.id);
if (__ottoman?.id === this.id) {
console.log(__ottoman.id, '__ottoman -> undefined');
(__ottoman as any) = undefined;
}
await this.cluster.close();
this._cluster = undefined;
}
}

Expand Down

0 comments on commit bfae1b2

Please sign in to comment.