[GH-ISSUE #215] [BUG] Randomly getting this error #1090

Closed
opened 2026-03-07 22:05:30 +03:00 by kerem · 2 comments
Owner

Originally created by @sujit-baniya on GitHub (Dec 3, 2020).
Original GitHub issue: https://github.com/hibiken/asynq/issues/215

Originally assigned to: @hibiken on GitHub.

panic: reflect: call of reflect.Value.Int on zero Value [recovered]
        panic: reflect: call of reflect.Value.Int on zero Value

goroutine 22 [running]:
encoding/json.(*encodeState).marshal.func1(0xc000147a58)
        /usr/local/go/src/encoding/json/encode.go:326 +0x85
panic(0x939e40, 0xc00028b9e0)
        /usr/local/go/src/runtime/panic.go:969 +0x175
reflect.Value.Int(...)
        /usr/local/go/src/reflect/value.go:998
encoding/json.intEncoder(0xc0006ce280, 0x0, 0x0, 0x0, 0xc0005b0100)
        /usr/local/go/src/encoding/json/encode.go:550 +0x1ca
encoding/json.mapEncoder.encode(0x9f2470, 0xc0006ce280, 0x93f180, 0xc0005bc0a0, 0x195, 0x100)
        /usr/local/go/src/encoding/json/encode.go:801 +0x35c
encoding/json.structEncoder.encode(0xc000338000, 0x9, 0x10, 0xc0003021e0, 0xc0006ce280, 0x9971c0, 0xc0005bc070, 0x199, 0x930100)
        /usr/local/go/src/encoding/json/encode.go:759 +0x2ab
encoding/json.ptrEncoder.encode(0xc000302240, 0xc0006ce280, 0x9168c0, 0xc0005bc070, 0x16, 0x910100)
        /usr/local/go/src/encoding/json/encode.go:915 +0x125
encoding/json.(*encodeState).reflectValue(0xc0006ce280, 0x9168c0, 0xc0005bc070, 0x16, 0xc000140100)
        /usr/local/go/src/encoding/json/encode.go:358 +0x82
encoding/json.(*encodeState).marshal(0xc0006ce280, 0x9168c0, 0xc0005bc070, 0xc0000f0100, 0x0, 0x0)
        /usr/local/go/src/encoding/json/encode.go:330 +0xf4
encoding/json.Marshal(0x9168c0, 0xc0005bc070, 0xc000036700, 0xc0001529c0, 0x2, 0x2, 0xc000152940)
        /usr/local/go/src/encoding/json/encode.go:161 +0x52
github.com/sujit-baniya/asynq/lib/rdb.(*RDB).WriteServerState(0xc0000eb380, 0xc0005bc070, 0x0, 0x0, 0x0, 0x2540be400, 0xc000147cb0, 0x447bd3)
        /home/sujit/Sites/labs/go/asynq/lib/rdb/rdb.go:539 +0x4f
github.com/sujit-baniya/asynq.(*heartbeater).beat(0xc0000a3180)
        /home/sujit/Sites/labs/go/asynq/heartbeat.go:165 +0x4dc
github.com/sujit-baniya/asynq.(*heartbeater).start.func1(0xc0002000c0, 0xc0000a3180)
        /home/sujit/Sites/labs/go/asynq/heartbeat.go:124 +0x43d
created by github.com/sujit-baniya/asynq.(*heartbeater).start
        /home/sujit/Sites/labs/go/asynq/heartbeat.go:107 +0x65

Place of issue


func (h *heartbeater) beat() {
	...

	if err := h.broker.WriteServerState(&info, ws, h.interval*2); err != nil {
		h.logger.Errorf("could not write server state data: %v", err)
	}
}

// WriteServerState writes server state data to redis with expiration set to the value ttl.
func (r *RDB) WriteServerState(info *base.ServerInfo, workers []*base.WorkerInfo, ttl time.Duration) error {
	bytes, err := json.Marshal(info) // Place of issue
        ...
}
Originally created by @sujit-baniya on GitHub (Dec 3, 2020). Original GitHub issue: https://github.com/hibiken/asynq/issues/215 Originally assigned to: @hibiken on GitHub. ```go panic: reflect: call of reflect.Value.Int on zero Value [recovered] panic: reflect: call of reflect.Value.Int on zero Value goroutine 22 [running]: encoding/json.(*encodeState).marshal.func1(0xc000147a58) /usr/local/go/src/encoding/json/encode.go:326 +0x85 panic(0x939e40, 0xc00028b9e0) /usr/local/go/src/runtime/panic.go:969 +0x175 reflect.Value.Int(...) /usr/local/go/src/reflect/value.go:998 encoding/json.intEncoder(0xc0006ce280, 0x0, 0x0, 0x0, 0xc0005b0100) /usr/local/go/src/encoding/json/encode.go:550 +0x1ca encoding/json.mapEncoder.encode(0x9f2470, 0xc0006ce280, 0x93f180, 0xc0005bc0a0, 0x195, 0x100) /usr/local/go/src/encoding/json/encode.go:801 +0x35c encoding/json.structEncoder.encode(0xc000338000, 0x9, 0x10, 0xc0003021e0, 0xc0006ce280, 0x9971c0, 0xc0005bc070, 0x199, 0x930100) /usr/local/go/src/encoding/json/encode.go:759 +0x2ab encoding/json.ptrEncoder.encode(0xc000302240, 0xc0006ce280, 0x9168c0, 0xc0005bc070, 0x16, 0x910100) /usr/local/go/src/encoding/json/encode.go:915 +0x125 encoding/json.(*encodeState).reflectValue(0xc0006ce280, 0x9168c0, 0xc0005bc070, 0x16, 0xc000140100) /usr/local/go/src/encoding/json/encode.go:358 +0x82 encoding/json.(*encodeState).marshal(0xc0006ce280, 0x9168c0, 0xc0005bc070, 0xc0000f0100, 0x0, 0x0) /usr/local/go/src/encoding/json/encode.go:330 +0xf4 encoding/json.Marshal(0x9168c0, 0xc0005bc070, 0xc000036700, 0xc0001529c0, 0x2, 0x2, 0xc000152940) /usr/local/go/src/encoding/json/encode.go:161 +0x52 github.com/sujit-baniya/asynq/lib/rdb.(*RDB).WriteServerState(0xc0000eb380, 0xc0005bc070, 0x0, 0x0, 0x0, 0x2540be400, 0xc000147cb0, 0x447bd3) /home/sujit/Sites/labs/go/asynq/lib/rdb/rdb.go:539 +0x4f github.com/sujit-baniya/asynq.(*heartbeater).beat(0xc0000a3180) /home/sujit/Sites/labs/go/asynq/heartbeat.go:165 +0x4dc github.com/sujit-baniya/asynq.(*heartbeater).start.func1(0xc0002000c0, 0xc0000a3180) /home/sujit/Sites/labs/go/asynq/heartbeat.go:124 +0x43d created by github.com/sujit-baniya/asynq.(*heartbeater).start /home/sujit/Sites/labs/go/asynq/heartbeat.go:107 +0x65 ``` Place of issue ```go func (h *heartbeater) beat() { ... if err := h.broker.WriteServerState(&info, ws, h.interval*2); err != nil { h.logger.Errorf("could not write server state data: %v", err) } } // WriteServerState writes server state data to redis with expiration set to the value ttl. func (r *RDB) WriteServerState(info *base.ServerInfo, workers []*base.WorkerInfo, ttl time.Duration) error { bytes, err := json.Marshal(info) // Place of issue ... } ```
kerem 2026-03-07 22:05:30 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@hibiken commented on GitHub (Dec 3, 2020):

Thank you for reporting this.
A couple of things I want from your side:

  • Please include the package version number that produces this error
  • Please detail the steps to reproduce the error

From what I see in the log output, you are seeing in this error from your forked version of the package. Can you confirm that this error happens with the original?

<!-- gh-comment-id:738034630 --> @hibiken commented on GitHub (Dec 3, 2020): Thank you for reporting this. A couple of things I want from your side: - Please include the package version number that produces this error - Please detail the steps to reproduce the error From what I see in the log output, you are seeing in this error from your forked version of the package. Can you confirm that this error happens with the original?
Author
Owner

@sujit-baniya commented on GitHub (Dec 4, 2020):

Hi @hibiken I didn't test on original repo but replacing encoding/json with https://github.com/json-iterator/go seems to have fixed the issue.

Thanks for the response 👍🏼

<!-- gh-comment-id:738822757 --> @sujit-baniya commented on GitHub (Dec 4, 2020): Hi @hibiken I didn't test on original repo but replacing `encoding/json` with https://github.com/json-iterator/go seems to have fixed the issue. Thanks for the response 👍🏼
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#1090
No description provided.