@nestjs/core 11.1.23 → 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.
@@ -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.23",
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.23"
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": "b8be8c12270b2e6dcd275d435e573f08b4c79d79"
63
+ "gitHead": "d8a0ab829ddd8291b75109c9ac4fc4c7d070fc9e"
64
64
  }