Skip to content

[BUG] If deadline argument to WriteControl is deadline.IsZero() then 1000 hours (~41 days) are used as unexpected and undocumented fallback #895

Closed
@ghost

Description

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

If the deadline argument is deadline.IsZero() then 1000 hours are used instead:

websocket/conn.go

Lines 448 to 456 in d08ee1a

d := 1000 * time.Hour
if !deadline.IsZero() {
d = time.Until(deadline)
if d < 0 {
return errWriteTimeout
}
}

Expected Behavior

Behaviour should be documented and better design decision has to be made:

Either:

  • ignore zero as invalid argument: return errWriteTimeout.
  • ignore zero deadline: The maximum possible deadline should be used, not arbitrary value of 1000 hours.
  • respect zero as valid deadline: Fail request immediately.

Steps To Reproduce

Call WriteControl with a zero-deadline but fail to respond for ~41 days.

This is rather theoretical, but a non-conformant websocket or bad firewall might lead to this.

Anything else?

Originally reported in #841 (comment).
Confirmed as "unexpected" by maintainer in #841 (comment).

In practice probably doesn't affect anybody; it's just weird.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions