Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Transaction Promise.all with multiple queries results in Error: stream.push() after EOF #1908

@mrichardEA

Description

@mrichardEA

Upgrading to 6.5.0, we started encountering an issue when using Promise.all with multiple queries in a transaction.

This issue only started as of 6.5.0, (6.4.0 and earlier do not encounter this issue).

Possible culprits:

Environment details

  • OS: MacOS
  • Node.js version: 18.16.0
  • npm version: 9.5.1
  • @google-cloud/spanner version: 6.16.0

Steps to reproduce

  1. Create an async transaction that does 3 queries in a promise all:
		const spanner = new Spanner(<projectId>);
		const instance = spanner.instance(<instanceName>);
		const database = instance.database(<databaseName>);

		console.log('MJR instanceName', instanceName);
		console.log('MJR databaseName', databaseName);

		await database.runTransactionAsync(async (t) => {
			try {
				async function doRun(query: string): Promise<void> {
					console.log('Starting ', query);
					await t.run(query);
					console.log('Finished ', query);
				}

				const query1 = 'select * from trigger_offer';
				const query2 = 'select * from offer_purchases';
				const query3 = 'select * from active_offer';

				await Promise.all([doRun(query1), doRun(query2), doRun(query3)]);
				await t.commit();
			} catch (err) {
				console.log('MJR snapshot err', JSON.stringify(err));
			} finally {
				t.end();
			}
		});
		// Close the database when finished.
		await database.close();
		spanner.close();
  1. Running the code produced this output:
[node] MJR instanceName development
[node] MJR databaseName development_mrichard_amp
[node] Starting  select * from trigger_offer
[node] Starting  select * from offer_purchases
[node] Starting  select * from active_offer
[node] Finished  select * from trigger_offer
[node] uncaughtException stream.push() after EOF Error: stream.push() after EOF
[node]     at new NodeError (node:internal/errors:399:5)
[node]     at readableAddChunk (node:internal/streams/readable:285:30)
[node]     at PassThrough.Readable.push (node:internal/streams/readable:234:10)
[node]     at Immediate._onImmediate (/opt/amp/node_modules/@google-cloud/spanner/build/src/partial-result-stream.js:320:25)
[node]     at processImmediate (node:internal/timers:476:21)
[node]     at process.callbackTrampoline (node:internal/async_hooks:130:17)
[node] child process died with code 1
[node] restarting processes

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: spannerIssues related to the googleapis/nodejs-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions