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 72bf66926d
commit 9dfa8c7651
7 changed files with 37 additions and 4 deletions

View File

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

View File

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

View File

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

View File

@ -23,6 +23,8 @@ if (!LOADED && isDev() && !isTest()) {
LOADED = true
}
let inThread = false
module.exports = {
// important
PORT: process.env.PORT,
@ -62,6 +64,7 @@ module.exports = {
USERID_API_KEY: process.env.USERID_API_KEY,
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
DISABLE_THREADING: process.env.DISABLE_THREADING,
_set(key, value) {
process.env[key] = value
module.exports[key] = value
@ -72,6 +75,18 @@ module.exports = {
isProd: () => {
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

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 automationUtils = require("../automations/automationUtils")
const AutomationEmitter = require("../events/AutomationEmitter")
@ -6,7 +9,6 @@ const { DEFAULT_TENANT_ID } = require("@budibase/auth").constants
const CouchDB = require("../db")
const { DocumentTypes, isDevAppID } = require("../db/utils")
const { doInTenant } = require("@budibase/auth/tenancy")
const env = require("../environment")
const usage = require("../utilities/usageQuota")
const { definitions: triggerDefs } = require("../automations/triggerInfo")

View File

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