Skip to content

Document that singleton validators, mappers and event handlers are built from the root provider - #45

Merged
dj-nitehawk merged 1 commit into
FastEndpoints:devfrom
mbcrawfo:docs/create-singleton-root-provider
Sep 14, 2026
Merged

Document that singleton validators, mappers and event handlers are built from the root provider#45
dj-nitehawk merged 1 commit into
FastEndpoints:devfrom
mbcrawfo:docs/create-singleton-root-provider

Conversation

@mbcrawfo

Copy link
Copy Markdown
Contributor

Summary

Validators, mappers, processors and event handlers are singletons. They were built from the scope of the first request that needed them, so injecting a scoped service into their constructors captured that request's instance silently. FastEndpoints/FastEndpoints#1179 builds them from the root service provider instead.

  • Validator Dependencies: say validators are built from the root provider. Injecting a scoped dependency throws when DI scope validation is on (Development by default), but in Production it silently becomes a shared singleton, so the error can't be relied on alone.
  • Entity Mapper, Pre/Post Processor and Event Handler Dependencies: note the same root provider construction.

Validation

  • Changed file passes Prettier
  • Production documentation build passes

🤖 Generated with Claude Code

…ilt from the root provider

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants