mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
feat(editor): Add feature flag and binary data parsing for run data worker (no-changelog) (#19479)
This commit is contained in:
@@ -516,6 +516,7 @@ export const LOCAL_STORAGE_NDV_PANEL_WIDTH = 'N8N_NDV_PANEL_WIDTH';
|
||||
export const LOCAL_STORAGE_FOCUS_PANEL = 'N8N_FOCUS_PANEL';
|
||||
export const LOCAL_STORAGE_EXPERIMENTAL_DISMISSED_SUGGESTED_WORKFLOWS =
|
||||
'N8N_EXPERIMENTAL_DISMISSED_SUGGESTED_WORKFLOWS';
|
||||
export const LOCAL_STORAGE_RUN_DATA_WORKER = 'N8N_RUN_DATA_WORKER';
|
||||
|
||||
export const BASE_NODE_SURVEY_URL = 'https://n8n-community.typeform.com/to/BvmzxqYv#nodename=';
|
||||
export const COMMUNITY_PLUS_DOCS_URL =
|
||||
|
||||
@@ -7,6 +7,9 @@ import { useSettingsStore } from './settings.store';
|
||||
import { useRootStore } from '@n8n/stores/useRootStore';
|
||||
import { useWebSocketClient } from '@/push-connection/useWebSocketClient';
|
||||
import { useEventSourceClient } from '@/push-connection/useEventSourceClient';
|
||||
import { useLocalStorage } from '@vueuse/core';
|
||||
import { LOCAL_STORAGE_RUN_DATA_WORKER } from '@/constants';
|
||||
import { runDataWorker } from '@/workers/run-data/instance';
|
||||
|
||||
export type OnPushMessageHandler = (event: PushMessage) => void;
|
||||
|
||||
@@ -17,6 +20,8 @@ export const usePushConnectionStore = defineStore(STORES.PUSH, () => {
|
||||
const rootStore = useRootStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
const isRunDataWorkerEnabled = useLocalStorage<boolean>(LOCAL_STORAGE_RUN_DATA_WORKER, false);
|
||||
|
||||
/**
|
||||
* Queue of messages to be sent to the server. Messages are queued if
|
||||
* the connection is down.
|
||||
@@ -63,7 +68,12 @@ export const usePushConnectionStore = defineStore(STORES.PUSH, () => {
|
||||
// The `nodeExecuteAfterData` message is sent as binary data
|
||||
// to be handled by a web worker in the future.
|
||||
if (data instanceof ArrayBuffer) {
|
||||
data = new TextDecoder('utf-8').decode(new Uint8Array(data));
|
||||
if (isRunDataWorkerEnabled.value) {
|
||||
await runDataWorker.onNodeExecuteAfterData(data);
|
||||
return;
|
||||
} else {
|
||||
data = new TextDecoder('utf-8').decode(new Uint8Array(data));
|
||||
}
|
||||
}
|
||||
|
||||
let parsedData: PushMessage;
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as Comlink from 'comlink';
|
||||
import { databaseConfig } from '@/workers/run-data/db';
|
||||
import { initializeDatabase } from '@/workers/database';
|
||||
import type { Promiser, DbId } from '@sqlite.org/sqlite-wasm';
|
||||
import type { NodeExecuteAfterData } from '@n8n/api-types/push/execution';
|
||||
|
||||
const state: {
|
||||
initialized: boolean;
|
||||
@@ -23,6 +24,18 @@ export const actions = {
|
||||
state.dbId = dbId;
|
||||
state.initialized = true;
|
||||
},
|
||||
onNodeExecuteAfterData(buffer: ArrayBuffer) {
|
||||
const data = new TextDecoder('utf-8').decode(new Uint8Array(buffer));
|
||||
|
||||
let parsedData: NodeExecuteAfterData;
|
||||
try {
|
||||
parsedData = JSON.parse(data);
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('nodeExecuteAfterData in worker', parsedData);
|
||||
},
|
||||
};
|
||||
|
||||
export type RunDataWorker = typeof actions;
|
||||
|
||||
Reference in New Issue
Block a user