Fixing issue from review, values weren't wiped when delete modals closed, also adding a fix for threading to disable it in development as node-ts was causing memory leaks on low memory systems (doesn't apply to production built version).

This commit is contained in:
mike12345567 2021-11-22 17:42:41 +00:00
parent ea0000df51
commit 0335b1cee3
7 changed files with 37 additions and 4 deletions

View File

@ -180,6 +180,7 @@
function hideDeleteDialog() { function hideDeleteDialog() {
confirmDeleteDialog.hide() confirmDeleteDialog.hide()
deleteColName = ""
deletion = false deletion = false
} }

View File

@ -54,6 +54,10 @@
} }
} }
function hideDeleteDialog() {
deleteTableName = ""
}
async function save() { async function save() {
await tables.save(table) await tables.save(table)
notifications.success("Table renamed successfully") notifications.success("Table renamed successfully")
@ -98,6 +102,7 @@
bind:this={confirmDeleteDialog} bind:this={confirmDeleteDialog}
okText="Delete Table" okText="Delete Table"
onOk={deleteTable} onOk={deleteTable}
onCancel={hideDeleteDialog}
title="Confirm Deletion" title="Confirm Deletion"
disabled={deleteTableName !== table.name} disabled={deleteTableName !== table.name}
> >

View File

@ -50,6 +50,7 @@ async function init() {
SELF_HOSTED: 1, SELF_HOSTED: 1,
DISABLE_ACCOUNT_PORTAL: "", DISABLE_ACCOUNT_PORTAL: "",
MULTI_TENANCY: "", MULTI_TENANCY: "",
DISABLE_THREADING: 1,
} }
let envFile = "" let envFile = ""
Object.keys(envFileJson).forEach(key => { Object.keys(envFileJson).forEach(key => {

View File

@ -23,6 +23,8 @@ if (!LOADED && isDev() && !isTest()) {
LOADED = true LOADED = true
} }
let inThread = false
module.exports = { module.exports = {
// important // important
PORT: process.env.PORT, PORT: process.env.PORT,
@ -62,6 +64,7 @@ module.exports = {
USERID_API_KEY: process.env.USERID_API_KEY, USERID_API_KEY: process.env.USERID_API_KEY,
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL, DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
DISABLE_THREADING: process.env.DISABLE_THREADING,
_set(key, value) { _set(key, value) {
process.env[key] = value process.env[key] = value
module.exports[key] = value module.exports[key] = value
@ -72,6 +75,18 @@ module.exports = {
isProd: () => { isProd: () => {
return !isDev() return !isDev()
}, },
// used to check if already in a thread, don't thread further
setInThread: () => {
inThread = true
},
isInThread: () => {
return inThread
},
}
// threading can cause memory issues with node-ts in development
if (isDev() && module.exports.DISABLE_THREADING == null) {
module.exports._set("DISABLE_THREADING", "1")
} }
// clean up any environment variable edge cases // clean up any environment variable edge cases

View File

@ -1,3 +1,6 @@
// when thread starts, make sure it is recorded
const env = require("../environment")
env.setInThread()
const actions = require("../automations/actions") const actions = require("../automations/actions")
const automationUtils = require("../automations/automationUtils") const automationUtils = require("../automations/automationUtils")
const AutomationEmitter = require("../events/AutomationEmitter") const AutomationEmitter = require("../events/AutomationEmitter")
@ -6,7 +9,6 @@ const { DEFAULT_TENANT_ID } = require("@budibase/auth").constants
const CouchDB = require("../db") const CouchDB = require("../db")
const { DocumentTypes, isDevAppID } = require("../db/utils") const { DocumentTypes, isDevAppID } = require("../db/utils")
const { doInTenant } = require("@budibase/auth/tenancy") const { doInTenant } = require("@budibase/auth/tenancy")
const env = require("../environment")
const usage = require("../utilities/usageQuota") const usage = require("../utilities/usageQuota")
const { definitions: triggerDefs } = require("../automations/triggerInfo") const { definitions: triggerDefs } = require("../automations/triggerInfo")

View File

@ -24,10 +24,16 @@ function typeToFile(type) {
class Thread { class Thread {
constructor(type, opts = { timeoutMs: null, count: 1 }) { constructor(type, opts = { timeoutMs: null, count: 1 }) {
this.type = type this.type = type
if (!env.isTest()) { this.count = opts.count ? opts.count : 1
this.disableThreading =
env.isTest() ||
env.DISABLE_THREADING ||
this.count === 0 ||
env.isInThread()
if (!this.disableThreading) {
const workerOpts = { const workerOpts = {
autoStart: true, autoStart: true,
maxConcurrentWorkers: opts.count ? opts.count : 1, maxConcurrentWorkers: this.count,
} }
if (opts.timeoutMs) { if (opts.timeoutMs) {
workerOpts.maxCallTime = opts.timeoutMs workerOpts.maxCallTime = opts.timeoutMs
@ -40,7 +46,7 @@ class Thread {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let fncToCall let fncToCall
// if in test then don't use threading // if in test then don't use threading
if (env.isTest()) { if (this.disableThreading) {
fncToCall = require(typeToFile(this.type)) fncToCall = require(typeToFile(this.type))
} else { } else {
fncToCall = this.workers fncToCall = this.workers

View File

@ -1,3 +1,6 @@
// when thread starts, make sure it is recorded
const env = require("../environment")
env.setInThread()
const ScriptRunner = require("../utilities/scriptRunner") const ScriptRunner = require("../utilities/scriptRunner")
const { integrations } = require("../integrations") const { integrations } = require("../integrations")