Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX lts] Revert container deprecation #18729

Merged
merged 1 commit into from
Feb 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions packages/@ember/-internals/container/lib/container.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Factory, LookupOptions, Owner, OWNER, setOwner } from '@ember/-internals/owner';
import { dictionary, HAS_NATIVE_PROXY } from '@ember/-internals/utils';
import { EMBER_MODULE_UNIFICATION } from '@ember/canary-features';
import { assert, deprecate } from '@ember/debug';
import { assert } from '@ember/debug';
import { assign } from '@ember/polyfills';
import { DEBUG } from '@glimmer/env';
import Registry, { DebugRegistry, Injection } from './registry';
Expand Down Expand Up @@ -584,14 +584,6 @@ class FactoryManager<T, C> {
);
}

if (DEBUG) {
deprecate(
`Instantiating a new instance of ${this.fullName} while the owner is being destroyed is deprecated.`,
!container.isDestroying,
{ id: 'container.lookup-on-destroy', until: '3.20.0' }
);
}

let injectionsCache = this.injections;
if (injectionsCache === undefined) {
let { injections, isDynamic } = injectionsFor(this.container, this.normalizedName);
Expand Down
69 changes: 0 additions & 69 deletions packages/@ember/-internals/container/tests/container_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,75 +736,6 @@ moduleFor(
assert.deepEqual(Object.keys(instance), []);
}

'@test instantiating via container.lookup during destruction emits a deprecation'(assert) {
let registry = new Registry();
let container = registry.container();
class Service extends factory() {
destroy() {
expectDeprecation(() => {
container.lookup('service:other');
}, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/);
}
}
registry.register('service:foo', Service);
registry.register('service:other', factory());
let instance = container.lookup('service:foo');
assert.ok(instance, 'precond lookup successful');

runTask(() => {
container.destroy();
container.finalizeDestroy();
});
}

'@test instantiating via container.lookup during destruction enqueues destruction'(assert) {
Copy link
Member

@rwjblue rwjblue Feb 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should not have been removed. It is testing that things looked up during destruction are properly destroyed (aka the “correctness” fix mentioned in the PR description).

This should have removed the expectDeprecation wrapper around the lookup (since there is no deprecation now) but not the test assertions.

let registry = new Registry();
let container = registry.container();
let otherInstance;
class Service extends factory() {
destroy() {
expectDeprecation(() => {
otherInstance = container.lookup('service:other');
}, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/);

assert.ok(otherInstance.isDestroyed, 'service:other was destroyed');
}
}
registry.register('service:foo', Service);
registry.register('service:other', factory());
let instance = container.lookup('service:foo');
assert.ok(instance, 'precond lookup successful');

runTask(() => {
container.destroy();
container.finalizeDestroy();
});
}

'@test instantiating via container.factoryFor().create() during destruction emits a deprecation'(
assert
) {
let registry = new Registry();
let container = registry.container();
class Service extends factory() {
destroy() {
expectDeprecation(() => {
let Factory = container.factoryFor('service:other');
Factory.create();
}, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/);
}
}
registry.register('service:foo', Service);
registry.register('service:other', factory());
let instance = container.lookup('service:foo');
assert.ok(instance, 'precond lookup successful');

runTask(() => {
container.destroy();
container.finalizeDestroy();
});
}

'@test instantiating via container.factoryFor().create() after destruction throws an error'(
assert
) {
Expand Down