Skip to content

how to appropriate close(interrupt) stream result before end event ? #664

@jimmyolo

Description

@jimmyolo

as title, how to correctly interrupt stream results?
In mysqljs, I call .end(). that will trigger end event, then close stream
but in mysql2, TypeError: query.end is not a function
here is my code sample

// getConnection from pool
const query = conn.query('SELECT * FROM `table`')
    .on('result', (aRow)=>{
        // I handle one row and response to client, but if data is error or client disconnect, I need to stop res.
        // thus, i call query.end();
    })
    .on('end', ()=>{
        conn.release();
    });

I'm curiosity, query is readable stream or the other? but readable stream should not have end() method
should I call destroy() or close() preferable ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions