Skip to content

fix: close packet channel on non-temporary errors#1236

Draft
leno23 wants to merge 1 commit into
google:masterfrom
leno23:hermes-auto/gopacket-1143-packets-error-close
Draft

fix: close packet channel on non-temporary errors#1236
leno23 wants to merge 1 commit into
google:masterfrom
leno23:hermes-auto/gopacket-1143-packets-error-close

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

  • Close PacketSource.Packets() when NextPacket returns an unknown non-temporary error instead of retrying forever.
  • Match known retry/terminal errors through a small Unwrap-aware helper so wrapped errors are classified consistently without requiring errors.Is (the module still declares Go 1.12).
  • Add a regression test covering the starvation case where Packets() previously never closed after a persistent non-temporary read error.
  • Update Packets documentation to describe the non-temporary error behavior.

Related Issues / Closes

Closes #1143

Testing

  • go test . -run TestPacketSourcePacketsClosesOnNonTemporaryError -count=1 (passes)
  • go test . (passes)
  • go vet . (passes)
  • git diff --check (passes)

Additional validation:

  • I also ran go test ./...; it fails in unrelated platform/environment-dependent packages on this macOS runner:
    • examples/afpacket: Linux-only afpacket build constraints exclude all Go files.
    • pfring / examples/pfdump: missing system header pfring.h.
    • pcap: TestPCAPGoNgWrite reports could not read first packet: Read Error.

AI assistance disclosure

This draft PR was prepared with AI assistance from Hermes Agent. I reviewed the issue context, implemented the minimal change, and ran the validation listed above.

Signed-off-by: wuyangfan <1102042793@qq.com>
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 17, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(*PacketSource).packetsToChannel() error handling is incomplete

1 participant