Skip to content

Hanging promise after close() in flowing mode #2776

Open
@jichu4n

Description

@jichu4n

SerialPort Version

12.0.0

Node Version

v18.18.2

Electron Version

No response

Platform

Linux devfox 6.8.2-arch2-1 #1 SMP PREEMPT_DYNAMIC Thu, 28 Mar 2024 17:06:35 +0000 x86_64 GNU/Linux

Architecture

x64

Hardware or chipset of serialport

Prolific Technology, Inc. PL2303 Serial Port / Mobile Phone Data Cable

What steps will reproduce the bug?

  1. Attach a USB-to-serial adapter to the computer and leave the serial port side disconnected so no data is available to read.
  2. Create a SerialPort instance and attach a data callback: serialport.on('data', (data) => { ... }).
  3. Wait a few seconds, then close the SerialPort instance: serialport.close(...). (Adding pause() or destroy() produces the same result)

Minimal repro: serialport-test.ts

What happens?

Even after calling close() or destroy(), the promise created on unix-read.ts:41 never resolves / rejects. As a result, Node.js is prevented from exiting indefinitely.

See sample output from the minimal repro program above.

What should have happened?

The program should be able to exit cleanly after close() / destroy() is called.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions