Skip to content

SSE: cannot Close in callback #1047

@invzhi

Description

@invzhi

Hey, I'm using resty v3 to integrate dify.

Here is the problem I encountered: When I invoke Close in callback. The code execution will stuck.

eventSource.OnMessage(func(event any) {
	data := []byte(event.(*resty.Event).Data)
	var chunk struct {
		Event string `json:"event"`
	}
	_ = json.Unmarshal(data, &chunk)

	if chunk.Event == "message_end" {
		eventSource.Close()
	}
	fn(chunk.Event, data)
}, nil)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions