Skip to content

Commit

Permalink
fix: resolve memory leak, by cloning always from the main instance (#…
Browse files Browse the repository at this point in the history
…1110)

* fix: resolve memory leak, by cloneing always from the main instance

* Update src/createClient/node.ts

* Update src/createClient/node.ts

Co-authored-by: Isaac Hinman <isaac@isaachinman.com>
  • Loading branch information
adrai and isaachinman authored Mar 30, 2021
1 parent 5d9cf10 commit 2911d35
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/createClient/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import i18nextFSBackend from 'i18next-fs-backend'

import { InternalConfig, CreateClientReturn, InitPromise, I18n } from '../types'

let instance: I18n
let globalInstance: I18n

export default (config: InternalConfig): CreateClientReturn => {
if (!instance) {
instance = i18n.createInstance(config)
let instance: I18n
if (!globalInstance) {
globalInstance = i18n.createInstance(config)
instance = globalInstance
} else {
instance = instance.cloneInstance({
instance = globalInstance.cloneInstance({
...config,
initImmediate: false,
})
Expand Down

1 comment on commit 2911d35

@vercel
Copy link

@vercel vercel bot commented on 2911d35 Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.