Skip to content

queryStream hangs if sql has a logical error #1391

@awoodworth

Description

@awoodworth
  1. What versions are you using?
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
> process.platform
'darwin'
> process.version
'v14.15.0'
> process.arch
'x64'
> require('oracledb').versionString
'5.0.0'
> require('oracledb').oracleClientVersionString
'12.1.0.2.0'
  1. Is it an error or a hang or a crash?
crash I believe, but it causes my application to hang based on implementation
  1. What error(s) or behavior you are seeing?

The sql hangs/crashes when using queryStream if there's a logical error in the select/result set, but only if the error occurs after the first row. This does not occur when using execute.

  1. Include a runnable Node.js script that shows the problem.
const oracledb = require('oracledb');
const fs = require('fs');
const path = require('path');
const { Transform, pipeline } = require('stream');

// oracledb.initOracleClient({ libDir: '/usr/local/oracle/instantclient_19_3' });

let pool;
let conn;
const sql = 'select 1 from dual union all select 1 from dual union all select 1/0 from dual';

(async () => {
  try {
    pool = await oracledb.createPool({
      user: '',
      password: '',
      connectString: '',
    });
    conn = await pool.getConnection();

    const queryStream = conn.queryStream(sql, {}, { outFormat: oracledb.OUT_FORMAT_OBJECT });
    queryStream.on('error', console.error);
    queryStream.on('close', () => {
      console.log('queryStream CLOSED!');
      await conn.close();
      await pool.close(10);
    });

    // create other streams
    const transformStream = new Transform({
      objectMode: true,
      transform(chunk, encoding, callback) {
        console.log(chunk);
        return callback(null, JSON.stringify(chunk, null, 2));
      },
    });
    const writeStream = fs.createWriteStream(path.join(__dirname, 'output.json'));
    writeStream.on('finish', () => {
      console.log('DONE!');
    });

    // run the stream
    pipeline(queryStream, transformStream, writeStream, (err) => {
      if (err) console.error(err);
    });
  } catch (err) {
    console.error(err);
  }
})();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions