@nestjs/core 11.1.22 → 11.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Readme.md CHANGED
@@ -129,6 +129,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
129
129
  <tr>
130
130
  <td align="center" valign="middle"><a href="https://solcellsforetag.se/" target="_blank"><img src="https://nestjs.com/img/logos/solcellsforetag-logo.svg" width="140" valign="middle" /></a></td>
131
131
  <td align="center" valign="middle"><a href="https://www.route4me.com/" target="_blank"><img src="https://nestjs.com/img/logos/route4me-logo.svg" width="100" valign="middle" /></a></td>
132
+ <td align="center" valign="middle"><a href="https://memory2.co/" target="_blank"><img src="https://images.opencollective.com/memory-squared/bbe37f5/avatar/256.png?height=50" width="50" valign="middle" /></a></td>
132
133
  </tr>
133
134
  </table>
134
135
 
@@ -504,7 +504,6 @@ class Injector {
504
504
  wrapper.isExplicitlyRequested(resolutionContext.contextId, resolutionContext.inquirer));
505
505
  }
506
506
  shouldSkipProviderLoading(wrapper, resolutionContext) {
507
- const isSnapshotGraphCompilation = !!this.options?.snapshot;
508
507
  const isStaticContext = resolutionContext.contextId === constants_2.STATIC_CONTEXT;
509
508
  const hasNoInquirer = !resolutionContext.inquirer;
510
509
  const isTopLevelStaticTransientOrRequestProvider = hasNoInquirer && (wrapper.isTransient || wrapper.scope === common_1.Scope.REQUEST);
@@ -513,7 +512,7 @@ class Injector {
513
512
  const shouldSkipForStaticBootstrap = isStaticContext &&
514
513
  (isTopLevelStaticTransientOrRequestProvider ||
515
514
  isStaticInquirerOutsideResolutionContext);
516
- return !isSnapshotGraphCompilation && shouldSkipForStaticBootstrap;
515
+ return shouldSkipForStaticBootstrap;
517
516
  }
518
517
  /**
519
518
  * For nested TRANSIENT dependencies (TRANSIENT -> TRANSIENT) in non-static contexts,
@@ -91,6 +91,8 @@ export declare class InstanceWrapper<T = any> {
91
91
  getStaticTransientInstances(): (InstancePerContext<T> | undefined)[];
92
92
  mergeWith(provider: Provider): void;
93
93
  private isNewable;
94
+ private registerDependencyTreeParent;
95
+ private resetDependencyTreeState;
94
96
  private initialize;
95
97
  private printIntrospectedAsRequestScoped;
96
98
  private printIntrospectedAsDurable;
@@ -12,6 +12,7 @@ const constants_1 = require("./constants");
12
12
  const provider_classifier_1 = require("./helpers/provider-classifier");
13
13
  exports.INSTANCE_METADATA_SYMBOL = Symbol.for('instance_metadata:cache');
14
14
  exports.INSTANCE_ID_SYMBOL = Symbol.for('instance_metadata:id');
15
+ const dependencyTreeParents = new WeakMap();
15
16
  class InstanceWrapper {
16
17
  constructor(metadata = {}) {
17
18
  this.isAlias = false;
@@ -99,6 +100,8 @@ class InstanceWrapper {
99
100
  this[exports.INSTANCE_METADATA_SYMBOL].dependencies = [];
100
101
  }
101
102
  this[exports.INSTANCE_METADATA_SYMBOL].dependencies[index] = wrapper;
103
+ this.registerDependencyTreeParent(wrapper);
104
+ this.resetDependencyTreeState();
102
105
  }
103
106
  getCtorMetadata() {
104
107
  return this[exports.INSTANCE_METADATA_SYMBOL].dependencies;
@@ -111,6 +114,8 @@ class InstanceWrapper {
111
114
  key,
112
115
  wrapper,
113
116
  });
117
+ this.registerDependencyTreeParent(wrapper);
118
+ this.resetDependencyTreeState();
114
119
  }
115
120
  getPropertiesMetadata() {
116
121
  return this[exports.INSTANCE_METADATA_SYMBOL].properties;
@@ -120,6 +125,8 @@ class InstanceWrapper {
120
125
  this[exports.INSTANCE_METADATA_SYMBOL].enhancers = [];
121
126
  }
122
127
  this[exports.INSTANCE_METADATA_SYMBOL].enhancers.push(wrapper);
128
+ this.registerDependencyTreeParent(wrapper);
129
+ this.resetDependencyTreeState();
123
130
  }
124
131
  getEnhancersMetadata() {
125
132
  return this[exports.INSTANCE_METADATA_SYMBOL].enhancers;
@@ -311,6 +318,24 @@ class InstanceWrapper {
311
318
  isNewable() {
312
319
  return (0, shared_utils_1.isNil)(this.inject) && this.metatype && this.metatype.prototype;
313
320
  }
321
+ registerDependencyTreeParent(wrapper) {
322
+ if (wrapper instanceof InstanceWrapper) {
323
+ const parents = dependencyTreeParents.get(wrapper) ?? new Set();
324
+ parents.add(this);
325
+ dependencyTreeParents.set(wrapper, parents);
326
+ }
327
+ }
328
+ resetDependencyTreeState(lookupRegistry = new Set()) {
329
+ if (lookupRegistry.has(this[exports.INSTANCE_ID_SYMBOL])) {
330
+ return;
331
+ }
332
+ lookupRegistry.add(this[exports.INSTANCE_ID_SYMBOL]);
333
+ this.isTreeStatic = undefined;
334
+ this.isTreeDurable = undefined;
335
+ dependencyTreeParents
336
+ .get(this)
337
+ ?.forEach(parent => parent.resetDependencyTreeState(lookupRegistry));
338
+ }
314
339
  initialize(metadata) {
315
340
  const { instance, isResolved, ...wrapperPartial } = metadata;
316
341
  Object.assign(this, wrapperPartial);
@@ -22,6 +22,7 @@ export declare class NestApplication extends NestApplicationContext<NestApplicat
22
22
  private readonly microservices;
23
23
  private httpServer;
24
24
  private isListening;
25
+ private isWsModuleRegistered;
25
26
  constructor(container: NestContainer, httpAdapter: HttpServer, config: ApplicationConfig, graphInspector: GraphInspector, appOptions?: NestApplicationOptions);
26
27
  protected dispose(): Promise<void>;
27
28
  getHttpAdapter(): AbstractHttpAdapter;
@@ -35,6 +35,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
35
35
  this.socketModule = SocketModule && new SocketModule();
36
36
  this.microservices = [];
37
37
  this.isListening = false;
38
+ this.isWsModuleRegistered = false;
38
39
  this.selectContextModule();
39
40
  this.registerHttpServer();
40
41
  this.injector = new injector_1.Injector({
@@ -89,6 +90,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
89
90
  return;
90
91
  }
91
92
  this.socketModule.register(this.container, this.config, this.graphInspector, this.appOptions, this.httpServer);
93
+ this.isWsModuleRegistered = true;
92
94
  }
93
95
  async init() {
94
96
  if (this.isInitialized) {
@@ -252,6 +254,9 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
252
254
  return this;
253
255
  }
254
256
  useWebSocketAdapter(adapter) {
257
+ if (this.isWsModuleRegistered) {
258
+ this.logger.warn('useWebSocketAdapter() was called after WebSocket gateways were already initialized. The provided adapter will be stored but will NOT be applied to existing gateways — they remain bound to the previously installed adapter. To install a custom adapter, call app.useWebSocketAdapter(...) BEFORE app.init() (or app.listen()).');
259
+ }
255
260
  this.config.setIoAdapter(adapter);
256
261
  return this;
257
262
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "11.1.22",
3
+ "version": "11.1.24",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@core)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "uid": "2.0.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@nestjs/common": "11.1.22"
42
+ "@nestjs/common": "11.1.24"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@nestjs/common": "^11.0.0",
@@ -60,5 +60,5 @@
60
60
  "optional": true
61
61
  }
62
62
  },
63
- "gitHead": "801c46ffa19d2a549adc446d1f91e7484ae61edb"
63
+ "gitHead": "d8a0ab829ddd8291b75109c9ac4fc4c7d070fc9e"
64
64
  }