Skip to content

QUIC ping doesn't function properly #36462

@battall

Description

@battall

What steps will reproduce the bug?

const socket = net.createQuicSocket({ endpoint: { port: 555 } });

socket
  .on("session", (session) => {
    console.time("close");
    session.on("close", () => {
      console.timeEnd("close");
      console.log("close but why?", session.idleTimeout);
      // Output:
    });
  })
  .listen({
    alpn: "tunnel",
    key: fs.readFileSync(process.env.TLS_KEY_PATH, "utf8"),
    cert: fs.readFileSync(process.env.TLS_CERT_PATH, "utf8"),
    ca: fs.readFileSync(process.env.TLS_CA_PATH, "utf8"),
  });

socket
  .connect({
    address: "127.0.0.1",
    port: 555,
    alpn: "tunnel",
  })
  .then((session) => {
    setInterval(() => session.ping(), 100);
    session.openStream().then((stream) => {
      // Send data after 15 seconds
      setTimeout(() => {
        stream.write("hi");
      }, 15 * 1000);
    });
  });

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

session.ping() should reset idle timeout as said in docs
https://nodejs.org/api/quic.html#quic_quicsession_ping
but it does not reset timeout, session still ends after 10 seconds

What do you see instead?

node:internal/quic/core:2136
      throw new ERR_INVALID_STATE(
      ^

Error [ERR_INVALID_STATE]: Invalid state: QuicClientSession is already destroyed
    at new NodeError (node:internal/errors:278:15)
    at QuicClientSession.ping (node:internal/quic/core:2136:13)
    at Timeout._onTimeout (/home/debian/localport-server/test.js:34:31)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499:7) {
  code: 'ERR_INVALID_STATE'
}

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    quicIssues and PRs related to the QUIC implementation / HTTP/3.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions