Commit d633c8b
refactor: add
## Summary
- Adds `Configuration.reset()` as a discoverable static method on the
new v4 `Configuration` class. Delegates to `serviceLocator.reset()` so
the cached configuration, event manager, storage client, and logger are
all dropped together.
- Adds a test verifying that after `Configuration.reset()`, the next
`Configuration.getGlobalConfig()` re-reads `process.env`.
## Motivation
v4 `Configuration` resolves env vars eagerly at construction, so tests
that mutate `process.env` after the global singleton has been resolved
need a way to drop the cached instance. Today that's either
`serviceLocator.reset()` (works, but the name suggests "service tree"
rather than "the config I just changed env vars for") or reaching into
the private `Configuration.globalConfig` via type assertions (currently
happening across multiple test files in `apify-sdk-js`).
A class-side `Configuration.reset()` makes the intent obvious from the
call site and lives next to `Configuration.getGlobalConfig()` in
autocomplete. The implementation just delegates to
`serviceLocator.reset()` rather than resetting only the configuration —
resetting only the config would leave a stale `EventManager` /
`StorageClient` / logger holding the old config, which is the wrong
contract for callers wanting to "start fresh".
## Test plan
- [x] `vitest run packages/core/test/core/configuration.test.ts -t
"reset"`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Configuration.reset() static method (#3649)1 parent 20b320a commit d633c8b
2 files changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
208 | 223 | | |
209 | 224 | | |
210 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
320 | 334 | | |
0 commit comments