diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.js index 11ee28dbe8..fc9e2a21fc 100644 --- a/packages/server/src/threads/automation.js +++ b/packages/server/src/threads/automation.js @@ -1,6 +1,5 @@ -// when thread starts, make sure it is recorded +require("./utils").threadSetup() const env = require("../environment") -env.setInThread() const actions = require("../automations/actions") const automationUtils = require("../automations/automationUtils") const AutomationEmitter = require("../events/AutomationEmitter") diff --git a/packages/server/src/threads/query.js b/packages/server/src/threads/query.js index 6b0d021e94..6921a6543d 100644 --- a/packages/server/src/threads/query.js +++ b/packages/server/src/threads/query.js @@ -1,6 +1,4 @@ -// when thread starts, make sure it is recorded -const env = require("../environment") -env.setInThread() +require("./utils").threadSetup() const ScriptRunner = require("../utilities/scriptRunner") const { integrations } = require("../integrations") diff --git a/packages/server/src/threads/utils.js b/packages/server/src/threads/utils.js new file mode 100644 index 0000000000..13e9daf711 --- /dev/null +++ b/packages/server/src/threads/utils.js @@ -0,0 +1,9 @@ +const env = require("../environment") +const CouchDB = require("../db") +const { init } = require("@budibase/auth") + +exports.threadSetup = () => { + // when thread starts, make sure it is recorded + env.setInThread() + init(CouchDB) +}