diff --git a/lerna.json b/lerna.json index ae03c0334b..9d0fb72b23 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.19.0", + "version": "2.19.1", "npmClient": "yarn", "packages": [ "packages/*", diff --git a/packages/account-portal b/packages/account-portal index cc12291732..ba40a46748 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit cc12291732ee902dc832bc7d93cf2086ffdf0cff +Subproject commit ba40a467484963f8041144345469f4b395e31acc diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index ef529985b2..259128f6d4 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -341,7 +341,10 @@ const exportDataHandler = async action => { format: action.parameters.type, columns: action.parameters.columns, }) - download(data, `${selection.tableId}.${action.parameters.type}`) + download( + new Blob([data], { type: "text/plain" }), + `${selection.tableId}.${action.parameters.type}` + ) } catch (error) { notificationStore.actions.error("There was an error exporting the data") } diff --git a/packages/server/package.json b/packages/server/package.json index 9d385c7664..e600e36bd3 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -103,6 +103,7 @@ "pouchdb-all-dbs": "1.1.1", "pouchdb-find": "7.2.2", "redis": "4", + "serialize-error": "^7.0.1", "server-destroy": "1.0.1", "snowflake-promise": "^4.5.0", "socket.io": "4.6.1", diff --git a/packages/server/src/jsRunner/index.ts b/packages/server/src/jsRunner/index.ts index 38cd0dd0d6..e39dab1313 100644 --- a/packages/server/src/jsRunner/index.ts +++ b/packages/server/src/jsRunner/index.ts @@ -3,6 +3,7 @@ import env from "../environment" import { setJSRunner, setOnErrorLog } from "@budibase/string-templates" import { context, logging, timers } from "@budibase/backend-core" import tracer from "dd-trace" +import { serializeError } from "serialize-error" type TrackerFn = (f: () => T) => T @@ -61,7 +62,7 @@ export function init() { if (env.LOG_JS_ERRORS) { setOnErrorLog((error: Error) => { - logging.logWarn(JSON.stringify(error)) + logging.logWarn(JSON.stringify(serializeError(error))) }) } } diff --git a/packages/server/src/threads/utils.ts b/packages/server/src/threads/utils.ts index a0f3bbdc47..cd547cacae 100644 --- a/packages/server/src/threads/utils.ts +++ b/packages/server/src/threads/utils.ts @@ -2,6 +2,7 @@ import { QueryVariable } from "./definitions" import env from "../environment" import * as db from "../db" import { redis, db as dbCore } from "@budibase/backend-core" +import * as jsRunner from "../jsRunner" const VARIABLE_TTL_SECONDS = 3600 let client: any @@ -29,7 +30,9 @@ export function threadSetup() { console.debug(`[${env.FORKED_PROCESS_NAME}] thread setup skipped`) return } + console.debug(`[${env.FORKED_PROCESS_NAME}] thread setup running`) + jsRunner.init() db.init() } diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 12a94f5a2f..777896a7f7 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "@budibase/types": "0.0.0", - "cron-validate": "^1.4.5" + "cron-validate": "1.4.5" }, "devDependencies": { "rimraf": "3.0.2", diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js index f370b67272..bcd63d2e6f 100644 --- a/packages/string-templates/src/index.js +++ b/packages/string-templates/src/index.js @@ -1,3 +1,4 @@ +const vm = require("vm") const handlebars = require("handlebars") const { registerAll, registerMinimum } = require("./helpers/index") const processors = require("./processors") @@ -402,3 +403,19 @@ const errors = require("./errors") module.exports.JsErrorTimeout = errors.JsErrorTimeout module.exports.helpersToRemoveForJs = helpersToRemoveForJs + +if (process && !process.env.NO_JS) { + /** + * Use polyfilled vm to run JS scripts in a browser Env + */ + javascript.setJSRunner((js, context) => { + context = { + ...context, + alert: undefined, + setInterval: undefined, + setTimeout: undefined, + } + vm.createContext(context) + return vm.runInNewContext(js, context, { timeout: 1000 }) + }) +} diff --git a/packages/string-templates/src/index.mjs b/packages/string-templates/src/index.mjs index 5ac7981fee..f54ca7e23e 100644 --- a/packages/string-templates/src/index.mjs +++ b/packages/string-templates/src/index.mjs @@ -1,4 +1,3 @@ -import vm from "vm" import templates from "./index.js" /** @@ -24,20 +23,4 @@ export const setOnErrorLog = templates.setOnErrorLog export const FIND_ANY_HBS_REGEX = templates.FIND_ANY_HBS_REGEX export const helpersToRemoveForJs = templates.helpersToRemoveForJs -if (process && !process.env.NO_JS) { - /** - * Use polyfilled vm to run JS scripts in a browser Env - */ - setJSRunner((js, context) => { - context = { - ...context, - alert: undefined, - setInterval: undefined, - setTimeout: undefined, - } - vm.createContext(context) - return vm.runInNewContext(js, context, { timeout: 1000 }) - }) -} - export * from "./errors.js" diff --git a/yarn.lock b/yarn.lock index defee1e6e1..fb2f777748 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8553,7 +8553,7 @@ cron-parser@^4.2.1: dependencies: luxon "^3.2.1" -cron-validate@^1.4.5: +cron-validate@1.4.5: version "1.4.5" resolved "https://registry.yarnpkg.com/cron-validate/-/cron-validate-1.4.5.tgz#eceb221f7558e6302e5f84c7b3a454fdf4d064c3" integrity sha512-nKlOJEnYKudMn/aNyNH8xxWczlfpaazfWV32Pcx/2St51r2bxWbGhZD7uwzMcRhunA/ZNL+Htm/i0792Z59UMQ==