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 4.4] Don't run getters while applying mixins #20405

Merged
merged 2 commits into from
Apr 27, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/alpha-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Alpha Releases

on:
schedule:
- cron: '0 20 * * 3' # weekly (Wednesday)
- cron: '0 20 * * 3' # weekly (Wednesday)

jobs:
test:
Expand All @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
registry-url: 'https://registry.npmjs.org'
- name: install dependencies
Expand Down
72 changes: 52 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
push:
branches:
- master
- main
- beta
- release
# release branches
Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -39,7 +39,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -66,7 +66,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -92,7 +92,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -115,7 +115,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -135,7 +135,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -156,7 +156,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -177,7 +177,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -198,7 +198,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -217,7 +217,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -236,13 +236,24 @@ jobs:
deploy-tag:
name: Deploy tags to npm
runs-on: ubuntu-latest
needs: [basic-test, lint, browserstack-test, production-test, production-debug-render-test, extend-prototypes-test, node-test, blueprint-test, browser-test]
needs:
[
basic-test,
lint,
browserstack-test,
production-test,
production-debug-render-test,
extend-prototypes-test,
node-test,
blueprint-test,
browser-test,
]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
registry-url: 'https://registry.npmjs.org'
cache: yarn
- name: install dependencies
Expand All @@ -257,14 +268,25 @@ jobs:
publish:
name: Publish channel to s3
runs-on: ubuntu-latest
needs: [basic-test, lint, browserstack-test, production-test, production-debug-render-test, extend-prototypes-test, node-test, blueprint-test, browser-test]
needs:
[
basic-test,
lint,
browserstack-test,
production-test,
production-debug-render-test,
extend-prototypes-test,
node-test,
blueprint-test,
browser-test,
]
# Only run on pushes to branches that are not from the cron workflow
if: github.event_name == 'push' && contains(github.ref, 'cron') != true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -280,14 +302,25 @@ jobs:
publish-alpha:
name: Publish alpha from default branch
runs-on: ubuntu-latest
needs: [basic-test, lint, browserstack-test, production-test, production-debug-render-test, extend-prototypes-test, node-test, blueprint-test, browser-test]
# Only run on pushes to master
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs:
[
basic-test,
lint,
browserstack-test,
production-test,
production-debug-render-test,
extend-prototypes-test,
node-test,
blueprint-test,
browser-test,
]
# Only run on pushes to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
Expand All @@ -301,4 +334,3 @@ jobs:
S3_BUCKET_NAME: 'builds.emberjs.com'
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY}}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID}}

4 changes: 2 additions & 2 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Cron

on:
schedule:
- cron: '0 7 * * *' # daily, 7am
- cron: '0 7 * * *' # daily, 7am

jobs:
trigger-ci:
Expand All @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
branch:
- master
- main
- beta
- release
steps:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"typescript": "~4.6.0"
},
"engines": {
"node": ">= 12.*"
"node": ">= 14.*"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we can bump this in a point release since it would be a breaking change that would be very unexpected. Bumping the version for a particular CI job should be fine though I am curious why it failed: theoretically the smoke test should work on 4.4 without changes.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't the rule about releases that each release supports whatever node version is still under maintenance?

Copy link
Member

Choose a reason for hiding this comment

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

We discussed on discord, but writing here as well: I think a node version bump in a patch release would be very surprising to users. The policy states only when we drop support on the primary branch of ember-cli https://github.com/ember-cli/ember-cli/blob/master/docs/node-support.md

},
"ember-addon": {
"after": "ember-cli-legacy-blueprints"
Expand Down
20 changes: 13 additions & 7 deletions packages/@ember/-internals/metal/lib/mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
descriptorForDecorator,
makeComputedDecorator,
nativeDescDecorator,
isClassicDecorator,
} from './decorator';
import { addListener, removeListener } from './events';
import expandProperties from './expand_properties';
Expand Down Expand Up @@ -230,7 +231,7 @@ function mergeMixins(
keys: string[],
keysWithSuper: string[]
): void {
let currentMixin;
let currentMixin: MixinLike | undefined;

for (let i = 0; i < mixins.length; i++) {
currentMixin = mixins[i];
Expand Down Expand Up @@ -304,12 +305,17 @@ function mergeProps(
let desc = meta.peekDescriptors(key);

if (desc === undefined) {
// The superclass did not have a CP, which means it may have
// observers or listeners on that property.
let prev = (values[key] = base[key]);

if (typeof prev === 'function') {
updateObserversAndListeners(base, key, prev, false);
// If the value is a classic decorator, we don't want to actually
// access it, because that will execute the decorator while we're
// building the class.
if (!isClassicDecorator(value)) {
// The superclass did not have a CP, which means it may have
// observers or listeners on that property.
let prev = (values[key] = base[key]);

if (typeof prev === 'function') {
updateObserversAndListeners(base, key, prev, false);
}
}
} else {
descs[key] = desc;
Expand Down
56 changes: 56 additions & 0 deletions packages/@ember/-internals/runtime/tests/mixins/accessor_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import EmberObject from '@ember/object';
import { moduleFor, RenderingTestCase } from 'internal-test-helpers';

moduleFor(
'runtime: Mixin Accessors',
class extends RenderingTestCase {
['@test works with getters'](assert) {
let value = 'building';

let Base = EmberObject.extend({
get foo() {
if (value === 'building') {
throw Error('base should not be called yet');
}

return "base's foo";
},
});

// force Base to be finalized so its properties will contain `foo`
Base.proto();

class Child extends Base {
get foo() {
if (value === 'building') {
throw Error('child should not be called yet');
}

return "child's foo";
}
}

Child.proto();

let Grandchild = Child.extend({
get foo() {
if (value === 'building') {
throw Error('grandchild should not be called yet');
}

return value;
},
});

let instance = Grandchild.create();

value = 'done building';

assert.equal(instance.foo, 'done building', 'getter defined correctly');

value = 'changed value';

assert.equal(instance.foo, 'changed value', 'the value is a real getter, not a snapshot');
}
}
);
2 changes: 1 addition & 1 deletion smoke-tests/ember-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"webpack": "^5.65.0"
},
"engines": {
"node": "12.* || 14.* || >= 16"
"node": "14.* || 16.* || >= 18"
},
"ember": {
"edition": "octane"
Expand Down