mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
a2f7367671
shutdown() unwires the stream and polling event handlers, but nothing wired them again. A client initialized after a shutdown opened a new connection and then ignored every datafile that connection delivered, so evaluations returned the default value with an error reason. The failure was silent: the socket was healthy and the fetch happened, only the handlers were missing. wireSourceEvents() now runs at the start of tryInitializeStream() and tryInitializePolling(), the only two places that start a source. Repeat calls cannot duplicate a subscription, because the handlers are stable instance properties and TypedEmitter keeps them in a Set. Two tests cover that invariant: one across a shutdown, and one for a source that starts twice within a single lifecycle, which happens when a failed initialization is followed by an evaluation. This also affects the VercelProvider OpenFeature provider, whose onClose() hook shuts the client down, since section 2.5.2 of the provider spec allows a provider to be initialized again after it is closed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>