Skip to content

Conversation

syrm
Copy link
Member

@syrm syrm commented Jun 8, 2024

No description provided.

Comment on lines 19 to 21
func Run(ctx context.Context, getenv func(string) string) error {
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt)
defer cancel()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signal.NotifyContext function is used to create a context that is canceled when an interrupt signal is received. However, the os.Interrupt signal is not the only signal that might require the application to gracefully shut down. Consider handling other termination signals like os.Kill and syscall.SIGTERM to ensure the application can handle a broader range of termination scenarios.

Comment on lines +29 to 31
return core.ConsumeActivity(ctx, nc, Name, []string{"activity.gaming"}, func(msg jetstream.Msg) error {
var event *events.PresenceUpdate
err := json.Unmarshal(msg.Data(), &event)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The json.Unmarshal function is used to decode the message data into the event variable. However, the event variable is declared as a pointer (*events.PresenceUpdate), but it is not initialized. This can lead to a nil pointer dereference if the json.Unmarshal fails. Ensure that the event variable is properly initialized before unmarshaling the JSON data.

@syrm syrm merged commit 5ebc6de into main Jun 8, 2024
@syrm syrm deleted the ci-fix branch June 8, 2024 20:49
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.

1 participant