Skip to content

Commit 055fab0

Browse files
committed
[BUGFIX lts] Revert container deprecation
We agreed that it was important to fix the error cases in #18717, but while the work may be unnecessary, there isn't necessarily any "correctness" issues with looking up things during destruction. Using a deprecation to warn about potentially "unnecessary" work is a bit heavy-handed, and at minimum requires some more continued discussions, so reverting that part of the PR for now (while keeping the errors in tact). (cherry picked from commit b853324)
1 parent 4f10138 commit 055fab0

File tree

2 files changed

+1
-78
lines changed

2 files changed

+1
-78
lines changed

packages/@ember/-internals/container/lib/container.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Factory, LookupOptions, Owner, OWNER, setOwner } from '@ember/-internals/owner';
22
import { dictionary, HAS_NATIVE_PROXY } from '@ember/-internals/utils';
33
import { EMBER_MODULE_UNIFICATION } from '@ember/canary-features';
4-
import { assert, deprecate } from '@ember/debug';
4+
import { assert } from '@ember/debug';
55
import { assign } from '@ember/polyfills';
66
import { DEBUG } from '@glimmer/env';
77
import Registry, { DebugRegistry, Injection } from './registry';
@@ -584,14 +584,6 @@ class FactoryManager<T, C> {
584584
);
585585
}
586586

587-
if (DEBUG) {
588-
deprecate(
589-
`Instantiating a new instance of ${this.fullName} while the owner is being destroyed is deprecated.`,
590-
!container.isDestroying,
591-
{ id: 'container.lookup-on-destroy', until: '3.20.0' }
592-
);
593-
}
594-
595587
let injectionsCache = this.injections;
596588
if (injectionsCache === undefined) {
597589
let { injections, isDynamic } = injectionsFor(this.container, this.normalizedName);

packages/@ember/-internals/container/tests/container_test.js

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -736,75 +736,6 @@ moduleFor(
736736
assert.deepEqual(Object.keys(instance), []);
737737
}
738738

739-
'@test instantiating via container.lookup during destruction emits a deprecation'(assert) {
740-
let registry = new Registry();
741-
let container = registry.container();
742-
class Service extends factory() {
743-
destroy() {
744-
expectDeprecation(() => {
745-
container.lookup('service:other');
746-
}, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/);
747-
}
748-
}
749-
registry.register('service:foo', Service);
750-
registry.register('service:other', factory());
751-
let instance = container.lookup('service:foo');
752-
assert.ok(instance, 'precond lookup successful');
753-
754-
runTask(() => {
755-
container.destroy();
756-
container.finalizeDestroy();
757-
});
758-
}
759-
760-
'@test instantiating via container.lookup during destruction enqueues destruction'(assert) {
761-
let registry = new Registry();
762-
let container = registry.container();
763-
let otherInstance;
764-
class Service extends factory() {
765-
destroy() {
766-
expectDeprecation(() => {
767-
otherInstance = container.lookup('service:other');
768-
}, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/);
769-
770-
assert.ok(otherInstance.isDestroyed, 'service:other was destroyed');
771-
}
772-
}
773-
registry.register('service:foo', Service);
774-
registry.register('service:other', factory());
775-
let instance = container.lookup('service:foo');
776-
assert.ok(instance, 'precond lookup successful');
777-
778-
runTask(() => {
779-
container.destroy();
780-
container.finalizeDestroy();
781-
});
782-
}
783-
784-
'@test instantiating via container.factoryFor().create() during destruction emits a deprecation'(
785-
assert
786-
) {
787-
let registry = new Registry();
788-
let container = registry.container();
789-
class Service extends factory() {
790-
destroy() {
791-
expectDeprecation(() => {
792-
let Factory = container.factoryFor('service:other');
793-
Factory.create();
794-
}, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/);
795-
}
796-
}
797-
registry.register('service:foo', Service);
798-
registry.register('service:other', factory());
799-
let instance = container.lookup('service:foo');
800-
assert.ok(instance, 'precond lookup successful');
801-
802-
runTask(() => {
803-
container.destroy();
804-
container.finalizeDestroy();
805-
});
806-
}
807-
808739
'@test instantiating via container.factoryFor().create() after destruction throws an error'(
809740
assert
810741
) {

0 commit comments

Comments
 (0)