Skip to content

Commit

Permalink
fix(Google Sheets Node): Fix "Maximum call stack size exceeded" error…
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Oct 9, 2023
1 parent c5ee06c commit 7cdff07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Expand Up @@ -7,7 +7,7 @@ import { GoogleSheetsV2 } from './v2/GoogleSheetsV2.node';
export class GoogleSheets extends VersionedNodeType {
constructor() {
const baseDescription: INodeTypeBaseDescription = {
displayName: 'Google Sheets ',
displayName: 'Google Sheets',
name: 'googleSheets',
icon: 'file:googleSheets.svg',
group: ['input', 'output'],
Expand Down
20 changes: 11 additions & 9 deletions packages/nodes-base/nodes/Google/Sheet/v2/actions/router.ts
Expand Up @@ -6,7 +6,7 @@ import { getSpreadsheetId } from '../helpers/GoogleSheets.utils';
import type { GoogleSheets, ResourceLocator } from '../helpers/GoogleSheets.types';

export async function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const operationResult: INodeExecutionData[] = [];
let operationResult: INodeExecutionData[] = [];

try {
const resource = this.getNodeParameter('resource', 0);
Expand All @@ -17,6 +17,7 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
operation,
} as GoogleSheets;

let results: INodeExecutionData[] | undefined;
if (googleSheets.resource === 'sheet') {
const { mode, value } = this.getNodeParameter('documentId', 0) as IDataObject;
const spreadsheetId = getSpreadsheetId(mode as ResourceLocator, value as string);
Expand Down Expand Up @@ -49,16 +50,17 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
sheetName = await googleSheet.spreadsheetGetSheetNameById(sheetId);
}

operationResult.push(
...(await sheet[googleSheets.operation].execute.call(
this,
googleSheet,
sheetName,
sheetId,
)),
results = await sheet[googleSheets.operation].execute.call(
this,
googleSheet,
sheetName,
sheetId,
);
} else if (googleSheets.resource === 'spreadsheet') {
operationResult.push(...(await spreadsheet[googleSheets.operation].execute.call(this)));
results = await spreadsheet[googleSheets.operation].execute.call(this);
}
if (results?.length) {
operationResult = operationResult.concat(results);
}
} catch (err) {
if (this.continueOnFail()) {
Expand Down

0 comments on commit 7cdff07

Please sign in to comment.