PR comments.

This commit is contained in:
mike12345567 2022-07-14 19:02:00 +01:00
parent c0b3ad155e
commit c692a656de
2 changed files with 4 additions and 4 deletions

View File

@ -1,13 +1,12 @@
const pouch = require("./pouch") const pouch = require("./pouch")
const env = require("../environment") const env = require("../environment")
const MEMORY_LEAK_CHECK = 0
const openDbs = [] const openDbs = []
let PouchDB let PouchDB
let initialised = false let initialised = false
const dbList = new Set() const dbList = new Set()
if (MEMORY_LEAK_CHECK) { if (env.MEMORY_LEAK_CHECK) {
setInterval(() => { setInterval(() => {
console.log("--- OPEN DBS ---") console.log("--- OPEN DBS ---")
console.log(openDbs) console.log(openDbs)
@ -44,7 +43,7 @@ exports.dangerousGetDB = (dbName, opts) => {
dbList.add(dbName) dbList.add(dbName)
} }
const db = new PouchDB(dbName, opts) const db = new PouchDB(dbName, opts)
if (MEMORY_LEAK_CHECK) { if (env.MEMORY_LEAK_CHECK) {
openDbs.push(db.name) openDbs.push(db.name)
} }
const dbPut = db.put const dbPut = db.put
@ -58,7 +57,7 @@ exports.closeDB = async db => {
if (!db || env.isTest()) { if (!db || env.isTest()) {
return return
} }
if (MEMORY_LEAK_CHECK) { if (env.MEMORY_LEAK_CHECK) {
openDbs.splice(openDbs.indexOf(db.name), 1) openDbs.splice(openDbs.indexOf(db.name), 1)
} }
try { try {

View File

@ -54,6 +54,7 @@ const env = {
DISABLE_DEVELOPER_LICENSE: process.env.DISABLE_DEVELOPER_LICENSE, DISABLE_DEVELOPER_LICENSE: process.env.DISABLE_DEVELOPER_LICENSE,
DEFAULT_LICENSE: process.env.DEFAULT_LICENSE, DEFAULT_LICENSE: process.env.DEFAULT_LICENSE,
SERVICE: process.env.SERVICE || "budibase", SERVICE: process.env.SERVICE || "budibase",
MEMORY_LEAK_CHECK: process.env.MEMORY_LEAK_CHECK || false,
DEPLOYMENT_ENVIRONMENT: DEPLOYMENT_ENVIRONMENT:
process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose", process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose",
_set(key: any, value: any) { _set(key: any, value: any) {