Skip to content

Can not catch Error in Stream Mode #997

Description

@Rafael-Dabrowski

When trying to make a query with a problem in the query eg. wrong columnname while in Stream mode event.js throws an error which can not be catched. Subscription to the "error" event will be processed but the underlying error will still be thrown. The error can not be catched in the query callback nor promise and leads to App Crash.

Expected behaviour:

Error should only be thrown through error Eventhandler or Promise/Callback.

Actual behaviour:

Error is thrown in error Event and within events.js:

events.js:174
      throw er; // Unhandled 'error' event
      ^

RequestError: Incorrect syntax near the keyword 'Table'.

Configuration:

sql
  .connect(connection)
  .then(pool => {
    let request = pool.request();
    request.stream = true;
    let sql = "SELECT nonsense FROM Table";   
    let ws = fs.createWriteStream("output.txt");
    request.on("error", err => {
      console.log("Error in Stream", err.code);
    });
   request.pipe(through).pipe(ws);
   request.query(sql).catch(err => {
       console.log("error in Promise", err.code);
   });
});

Software versions

  • NodeJS: 10.17.0
  • node-mssql: 6.1.0
  • SQL Server: 2017
  • Driver: Tedious

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions