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

fix(engine): issue #858 to enable the ability to have setters reactive #1038

Merged
merged 3 commits into from
Jun 28, 2019

Conversation

caridy
Copy link
Contributor

@caridy caridy commented Feb 6, 2019

Details

This PR is a refactor to organize the reactive mechanism so it can be used in other areas other than template rendering.

  • Enable the possibility to support reactive setters similarly to the rendering phase (pending to have the features flag).
  • Enable the possibility to support reactive wired methods similar to the rendering phase (pending to have the features flag).

Does this PR introduce a breaking change?

  • No

@salesforce-best-lwc-internal

This comment has been minimized.

@@ -79,23 +80,20 @@ export function linkComponent(vm: VM) {
}
}

export function clearReactiveListeners(vm: VM) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved this logic into watcher.

const set = deps[i];
const pos = ArrayIndexOf.call(deps[i], vm);
function getObservingTemplateRecord(vm: VM): ObservingRecord {
return {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the record created per component to observe things accessed from the template, with the corresponding notification mechanism (notify member) to be invoked when reactive objects observed by this record are updated.

@@ -104,7 +102,11 @@ export function renderComponent(vm: VM): VNodes {
assert.invariant(vm.isDirty, `${vm} is not dirty.`);
}

clearReactiveListeners(vm);
if (!isNull(vm.otr)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we cache the observing template record in the VM since it is a 1-1 to the component instance, and we create it only once (the first time the component is rendered)

Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible for vm to not be defined here?

Copy link
Collaborator

@apapko apapko Feb 10, 2019

Choose a reason for hiding this comment

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

Is there a consequence of caching here given that users can inject elements manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's not longer the case, now VM will always have elm and component, UninitializedVM on the other hand, doesn't

}

function getObservingAccessorRecord(vm: VM, set: (v: any) => void): ObservingAccessorRecord {
return {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this returns the record created per instance per public setter that can be used to track reactive objects used by the original setter invocation, so when those reactive objects are updated, the notify() method is invoked to re-execute the original setter.

const currentObservingRecordInception = getCurrentObservingRecord();
let oRecord = vm.oar[key as any];
if (!isUndefined(oRecord)) {
resetObservingRecord(oRecord);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

every time the setter is invoked from outside, we clear up the record, and execute the original setter to add new listeners to this record in case things changes from one invocation to another (if conditions and such)

@@ -87,6 +88,8 @@ export function invokeComponentRenderMethod(vm: VM): VNodes {
establishContext(context);
const isRenderingInception = isRendering;
const vmBeingRenderedInception = vmBeingRendered;
const currentObservingRecordInception = getCurrentObservingRecord();
setCurrentObservingRecord(vm.otr);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we were relying on vmBeingRendered in the pass but now we need the actual record... that's why we added this extra thing

export function notifyMutation(target: object, key: PropertyKey) {
if (process.env.NODE_ENV !== 'production') {
assert.invariant(!isRendering, `Mutating property ${toString(key)} of ${toString(target)} is not allowed during the rendering life-cycle of ${vmBeingRendered}.`);
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this file has the majority of the code changes... we moved all things related to watching and new records into this file...

Copy link
Member

Choose a reason for hiding this comment

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

More documentation explaining the different data structure and how they interact together, with maybe a schema, would greatly help here since this piece takes of the code requires a certain amount of time to wrap my head around.

if (observingRecords) {
for (let i = 0, len = observingRecords.length; i < len; i += 1) {
const oRecord = observingRecords[i];
oRecord.notify();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the pass, because we had only one type of observing records (it was the VM itself), we were carry on the actual logic... but now we have abstracted that out, and we just need to call the notify() method of the record, and each record can react in any way they want.

* notified.
*/
export function resetObservingRecord(oRecord: ObservingRecord) {
const { listeners } = oRecord;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

when a observing record needs to be reset, it means all reactive objects bound to that record for observability needs to be cleared up so when they change, this record is not notified anymore.

* - Accessor Invocation Phase
*/
export interface ObservingRecord {
readonly vm: VM;
Copy link
Contributor

Choose a reason for hiding this comment

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

This field vm on the ObservingRecord is not being used anywhere(or VSCode is lying about its references :D ). Can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right! I was using it before until I realized that the one from the closure is sufficient.

}
deps.length = 0;
}
if (!vm.isDirty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you meant to read the vm from the ObservingRecord instead of creating a closure on the function param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, we always have that dilema, closure or local ref... will try both... whatever is faster

Copy link
Member

Choose a reason for hiding this comment

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

Did you made any performance measurement for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have done it in the past I think @pmdartus but it is tricky... honestly, I don't remember the conclusion.

if (process.env.NODE_ENV !== 'production') {
assert.invariant(pos > -1, `when clearing up deps, the vm must be part of the collection.`);
assert.invariant(!isRendering, `Mutating property is not allowed during the rendering life-cycle of ${vmBeingRendered}.`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it be more clear to the developers if we used an element name or a component in this message?

@@ -104,7 +102,11 @@ export function renderComponent(vm: VM): VNodes {
assert.invariant(vm.isDirty, `${vm} is not dirty.`);
}

clearReactiveListeners(vm);
if (!isNull(vm.otr)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible for vm to not be defined here?

@@ -104,7 +102,11 @@ export function renderComponent(vm: VM): VNodes {
assert.invariant(vm.isDirty, `${vm} is not dirty.`);
}

clearReactiveListeners(vm);
if (!isNull(vm.otr)) {
Copy link
Collaborator

@apapko apapko Feb 10, 2019

Choose a reason for hiding this comment

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

Is there a consequence of caching here given that users can inject elements manually?

@@ -102,6 +103,33 @@ function createPublicPropertyDescriptor(proto: ComponentConstructor, key: Proper
};
}

interface ObservingAccessorRecord extends ObservingRecord {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would something like ObservableRecord be more readable instead of Observing? To me, the name reads like an action in its current form

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a record that represents a accessor that is invoked during the observing phase, we already have a ObservableRecord for the actual object and the corresponding property from that obj.

@@ -102,6 +103,33 @@ function createPublicPropertyDescriptor(proto: ComponentConstructor, key: Proper
};
}

interface ObservingAccessorRecord extends ObservingRecord {
value?: any;
Copy link
Collaborator

Choose a reason for hiding this comment

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

how can we have an observed record without a value? Wouldn't we at least have undefined?

Copy link
Contributor Author

@caridy caridy Feb 13, 2019

Choose a reason for hiding this comment

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

when the record is created the first time, it is right before the value is handled and wrapped with a proxy, so, at this point we don't have it... additionally, it could be undefined, I think I can remove the ? and set it to undefined.

@@ -154,9 +158,18 @@ export function removeVM(vm: VM) {
return; // already removed
}
removeInsertionIndex(vm);
// just in case it comes back, with this we guarantee re-rendering it
const { oar, otr } = vm;
// Just in case it comes back, with this we guarantee re-rendering it
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this mean the removed vm can be re-added? In which scenario can this occur?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

root elements can be inserted and removed, and inserted back

resetObservingRecord(otr as ObservingRecord);
}
// Making sure that any observing accessor record will not trigger the setter to be reinvoked
for (const key in oar) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just reset the entire oar record?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a collection of records, each of then has their own cleaning mechanism to avoid notifications when the component is disconnected.

// used to track down all object-key pairs that makes this vm reactive
deps: [],
otr: null,
oar: create(null),
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do assigned values differ between oar and otr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

otr = observing template record
oar: observing accessor records

template you have only one per instance, accessors you have multiple accessors per instance.

}

/**
* An Observed Membre Property Record represents the list of all Observing Records,
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: member

return currentObservingRecord;
}

export function notifyMutation(target: object, key: PropertyKey) {
const reactiveRecord = TargetToReactiveRecordMap.get(target);
Copy link
Collaborator

Choose a reason for hiding this comment

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

in getReactiveRecord function, we set the value of the target to null. Wouldn't line 59 cause an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we never set it to null, we set it to a dictionary: Object.create(null)

@caridy caridy force-pushed the caridy/issue-858/reactive-setter branch from b93b0d8 to 8744689 Compare February 12, 2019 02:43
@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@caridy caridy force-pushed the caridy/issue-858/reactive-setter branch 2 times, most recently from d913363 to 793e88c Compare February 13, 2019 02:59
@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

}
deps.length = 0;
}
if (!vm.isDirty) {
Copy link
Member

Choose a reason for hiding this comment

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

This is part of the critical path you should probably use isFalse instead of !

}
deps.length = 0;
}
if (!vm.isDirty) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you made any performance measurement for this?

packages/@lwc/engine/src/framework/watcher.ts Outdated Show resolved Hide resolved
}
},
debouncing: false,
} as ObservingAccessorRecord;
Copy link
Member

Choose a reason for hiding this comment

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

You should not need to cast here, why not adding the vm field to ObservingAccessorRecord.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we had that in previous versions... but removed in favor of the always present closure.

vm,
value: undefined,
listeners: [],
notify(this: ObservingAccessorRecord) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a closure here and not store the set property on the ObservingAccessorRecord itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, still the question from above is lingering... is it really faster that way?

Copy link
Member

Choose a reason for hiding this comment

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

I think so, the creation of closure store an instance of the function + its context. We need to experiement here, but I think it would give allow us to mitigate the regression we currently have compared to master.

packages/@lwc/engine/src/framework/decorators/api.ts Outdated Show resolved Hide resolved
@@ -106,7 +103,11 @@ export function renderComponent(vm: VM): VNodes {
assert.invariant(vm.isDirty, `${vm} is not dirty.`);
}

clearReactiveListeners(vm);
if (!isNull(vm.otr)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not creating the otr at the VM creation time, we know for fact that the renderComponent will be invoked in the future. This would avoid an extra branching here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, in the past it was like that... I can do that.

packages/@lwc/engine/src/framework/watcher.ts Outdated Show resolved Hide resolved
return reactiveRecord;
}

export let currentObservingRecord: ObservingRecord | null = null;
Copy link
Member

Choose a reason for hiding this comment

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

currentObservingRecord should not be exported if there is a getter and a setter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you elaborate more?

Copy link
Member

Choose a reason for hiding this comment

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

currentObservingRecord is only consumed locally, I don't think it should be exported outside the module.

export function notifyMutation(target: object, key: PropertyKey) {
if (process.env.NODE_ENV !== 'production') {
assert.invariant(!isRendering, `Mutating property ${toString(key)} of ${toString(target)} is not allowed during the rendering life-cycle of ${vmBeingRendered}.`);
/**
Copy link
Member

Choose a reason for hiding this comment

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

More documentation explaining the different data structure and how they interact together, with maybe a schema, would greatly help here since this piece takes of the code requires a certain amount of time to wrap my head around.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: d1c54a8 | Target commit: bd6967a

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@caridy caridy force-pushed the caridy/issue-858/reactive-setter branch from 5952e05 to 6ef253d Compare June 3, 2019 01:40
@salesforce-best-lwc-internal

This comment has been minimized.

@caridy caridy force-pushed the caridy/issue-858/reactive-setter branch from 6ef253d to 32694a3 Compare June 3, 2019 16:15
@salesforce-cla
Copy link

salesforce-cla bot commented Jun 3, 2019

Thanks for the contribution! Before we can merge this, we need @caridy to sign the Salesforce.com Contributor License Agreement.

@salesforce-best-lwc-internal

This comment has been minimized.

fix(reactive-service): rebasing master

fix(reactive-service): delinting

fix(reactive-service): adding units

fix(reactive-service): pkg cleanup

fix(engine): perf optimizations on VM declaration
@caridy caridy force-pushed the caridy/issue-858/reactive-setter branch from 32694a3 to 60b4852 Compare June 25, 2019 16:58
@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 4395c22 | Target commit: 60b4852

lwc-engine-benchmark

table-append-1k metric base(4395c22) target(60b4852) trend
benchmark-table/append/1k duration 145.60 (±5.65 ms) 144.05 (±3.40 ms) -1.5ms (1.1%) 👌
table-clear-1k metric base(4395c22) target(60b4852) trend
benchmark-table/clear/1k duration 10.60 (±0.90 ms) 11.10 (±1.05 ms) +0.5ms (4.7%) 👌
table-create-10k metric base(4395c22) target(60b4852) trend
benchmark-table/create/10k duration 860.65 (±6.90 ms) 875.00 (±5.65 ms) +14.3ms (1.7%) 👎
table-create-1k metric base(4395c22) target(60b4852) trend
benchmark-table/create/1k duration 109.45 (±2.90 ms) 110.60 (±2.60 ms) +1.2ms (1.1%) 👌
table-update-10th-1k metric base(4395c22) target(60b4852) trend
benchmark-table/update-10th/1k duration 69.70 (±1.80 ms) 68.65 (±2.00 ms) -1.0ms (1.5%) 👌
tablecmp-append-1k metric base(4395c22) target(60b4852) trend
benchmark-table-component/append/1k duration 215.50 (±14.80 ms) 230.55 (±12.20 ms) +15.1ms (7.0%) 👎
tablecmp-clear-1k metric base(4395c22) target(60b4852) trend
benchmark-table-component/clear/1k duration 7.60 (±1.50 ms) 6.65 (±1.15 ms) -0.9ms (12.5%) 👌
tablecmp-create-10k metric base(4395c22) target(60b4852) trend
benchmark-table-component/create/10k duration 1618.10 (±8.70 ms) 1628.75 (±15.65 ms) +10.7ms (0.7%) 👎
tablecmp-create-1k metric base(4395c22) target(60b4852) trend
benchmark-table-component/create/1k duration 188.55 (±4.10 ms) 189.60 (±5.20 ms) +1.0ms (0.6%) 👌
tablecmp-update-10th-1k metric base(4395c22) target(60b4852) trend
benchmark-table-component/update-10th/1k duration 71.55 (±5.25 ms) 69.65 (±6.50 ms) -1.9ms (2.7%) 👌
wc-append-1k metric base(4395c22) target(60b4852) trend
benchmark-table-wc/append/1k duration 232.45 (±14.80 ms) 234.75 (±10.15 ms) +2.3ms (1.0%) 👌
wc-clear-1k metric base(4395c22) target(60b4852) trend
benchmark-table-wc/clear/1k duration 12.70 (±1.50 ms) 11.10 (±2.00 ms) -1.6ms (12.6%) 👍
wc-create-10k metric base(4395c22) target(60b4852) trend
benchmark-table-wc/create/10k duration 1904.95 (±12.90 ms) 1862.10 (±11.95 ms) -42.9ms (2.2%) 👍
wc-create-1k metric base(4395c22) target(60b4852) trend
benchmark-table-wc/create/1k duration 223.20 (±5.55 ms) 227.15 (±3.65 ms) +4.0ms (1.8%) 👎
wc-update-10th-1k metric base(4395c22) target(60b4852) trend
benchmark-table-wc/update-10th/1k duration 67.00 (±4.65 ms) 69.45 (±5.25 ms) +2.5ms (3.7%) 👌

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: cdc4558 | Target commit: e70fa62

lwc-engine-benchmark

table-append-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table/append/1k duration 144.90 (±3.90 ms) 140.80 (±4.45 ms) -4.1ms (2.8%) 👍
table-clear-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table/clear/1k duration 10.95 (±0.95 ms) 10.40 (±0.85 ms) -0.5ms (5.0%) 👍
table-create-10k metric base(cdc4558) target(e70fa62) trend
benchmark-table/create/10k duration 856.75 (±5.60 ms) 852.20 (±5.35 ms) -4.5ms (0.5%) 👍
table-create-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table/create/1k duration 107.50 (±3.15 ms) 109.40 (±3.15 ms) +1.9ms (1.8%) 👎
table-update-10th-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table/update-10th/1k duration 75.35 (±5.70 ms) 74.80 (±5.40 ms) -0.5ms (0.7%) 👌
tablecmp-append-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-component/append/1k duration 228.70 (±13.35 ms) 229.05 (±11.75 ms) +0.4ms (0.2%) 👌
tablecmp-clear-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-component/clear/1k duration 7.30 (±1.05 ms) 6.40 (±1.10 ms) -0.9ms (12.3%) 👍
tablecmp-create-10k metric base(cdc4558) target(e70fa62) trend
benchmark-table-component/create/10k duration 1603.10 (±10.60 ms) 1634.00 (±16.15 ms) +30.9ms (1.9%) 👎
tablecmp-create-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-component/create/1k duration 184.70 (±4.10 ms) 188.70 (±5.95 ms) +4.0ms (2.2%) 👎
tablecmp-update-10th-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-component/update-10th/1k duration 68.00 (±5.35 ms) 68.65 (±4.60 ms) +0.7ms (1.0%) 👌
wc-append-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-wc/append/1k duration 227.75 (±8.70 ms) 223.75 (±12.10 ms) -4.0ms (1.8%) 👌
wc-clear-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-wc/clear/1k duration 11.80 (±1.80 ms) 10.65 (±2.10 ms) -1.2ms (9.7%) 👌
wc-create-10k metric base(cdc4558) target(e70fa62) trend
benchmark-table-wc/create/10k duration 1874.90 (±11.30 ms) 1859.65 (±9.60 ms) -15.3ms (0.8%) 👍
wc-create-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-wc/create/1k duration 224.65 (±4.60 ms) 225.55 (±5.60 ms) +0.9ms (0.4%) 👌
wc-update-10th-1k metric base(cdc4558) target(e70fa62) trend
benchmark-table-wc/update-10th/1k duration 67.90 (±5.55 ms) 66.05 (±3.60 ms) -1.8ms (2.7%) 👌

valueMutated(o, 'x');
expect(changed).toBe(false);
});
it('should support observing and mutating the same value multiple times', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@caridy this (maybe other test?!) is throwing in the ci with error:

@lwc/engine: PASS lwc-engine src/libs/mutation-tracker/__tests__/index.spec.ts
@lwc/engine: (node:308) UnhandledPromiseRejectionWarning: Error: expect(received).toBe(expected) // Object.is equality
@lwc/engine: Expected: 2
@lwc/engine: Received: 1
@lwc/engine: (node:308) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
@lwc/engine: (node:308) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

does not seems to be doing anything async, or it does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a weird thing that I have been for a while... I don't know what is it, but it is not from this PR, I Can confirm that.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: cdc4558 | Target commit: db6fba6

lwc-engine-benchmark

table-append-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table/append/1k duration 144.90 (±3.90 ms) 143.35 (±4.30 ms) -1.5ms (1.1%) 👌
table-clear-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table/clear/1k duration 10.95 (±0.95 ms) 9.90 (±0.75 ms) -1.0ms (9.6%) 👍
table-create-10k metric base(cdc4558) target(db6fba6) trend
benchmark-table/create/10k duration 856.75 (±5.60 ms) 844.40 (±5.70 ms) -12.4ms (1.4%) 👍
table-create-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table/create/1k duration 107.50 (±3.15 ms) 106.30 (±1.95 ms) -1.2ms (1.1%) 👌
table-update-10th-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table/update-10th/1k duration 75.35 (±5.70 ms) 74.25 (±5.40 ms) -1.1ms (1.5%) 👌
tablecmp-append-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-component/append/1k duration 228.70 (±13.35 ms) 227.45 (±8.70 ms) -1.3ms (0.5%) 👌
tablecmp-clear-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-component/clear/1k duration 7.30 (±1.05 ms) 5.90 (±1.00 ms) -1.4ms (19.2%) 👍
tablecmp-create-10k metric base(cdc4558) target(db6fba6) trend
benchmark-table-component/create/10k duration 1603.10 (±10.60 ms) 1653.95 (±23.75 ms) +50.9ms (3.2%) 👎
tablecmp-create-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-component/create/1k duration 184.70 (±4.10 ms) 185.90 (±5.50 ms) +1.2ms (0.6%) 👌
tablecmp-update-10th-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-component/update-10th/1k duration 68.00 (±5.35 ms) 68.35 (±5.00 ms) +0.3ms (0.5%) 👌
wc-append-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-wc/append/1k duration 227.75 (±8.70 ms) 230.50 (±9.35 ms) +2.8ms (1.2%) 👌
wc-clear-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-wc/clear/1k duration 11.80 (±1.80 ms) 10.55 (±1.65 ms) -1.3ms (10.6%) 👍
wc-create-10k metric base(cdc4558) target(db6fba6) trend
benchmark-table-wc/create/10k duration 1874.90 (±11.30 ms) 1908.55 (±9.10 ms) +33.6ms (1.8%) 👎
wc-create-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-wc/create/1k duration 224.65 (±4.60 ms) 225.25 (±5.40 ms) +0.6ms (0.3%) 👌
wc-update-10th-1k metric base(cdc4558) target(db6fba6) trend
benchmark-table-wc/update-10th/1k duration 67.90 (±5.55 ms) 65.70 (±5.10 ms) -2.2ms (3.2%) 👌

import Parent from 'x/parent';

// TODO: issue #858 to enable reactive setters
xdescribe('Reactivity for setters', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this disabled? this should make them pass right?

Copy link
Contributor

Choose a reason for hiding this comment

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

also, should we remove the TODO on the line above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is not going to be squashed, it will have 3 commits, the second commit is the revert of the reactive setter until we get the feature flagging system that @ekashida is working on, once that lands, we enable this test, revert that second PR and enable the reactie setters :), this PR enables that to happen, doesn't change any functionality in the engine

Copy link
Contributor

@jodarove jodarove left a comment

Choose a reason for hiding this comment

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

Enable reactive setters tests.

Also, Im sure i'm missing something therefore ill like to know which part in the code solves the reactive setters. seems to me this only replaces the old reactivity system with the new mutation tracker?

Copy link
Contributor

@jodarove jodarove left a comment

Choose a reason for hiding this comment

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

Approving based on your comments

fix(engine): extracting out reactive-service into pkg mutation-tracker

fix(engine): extracting out reactive-service into libs/mutation-tracker

fix(engine): extracting out reactive-service into libs/mutation-tracker

fix(engine): extracting out reactive-service into libs/mutation-tracker
@caridy caridy force-pushed the caridy/issue-858/reactive-setter branch from db6fba6 to 5e0fa97 Compare June 28, 2019 01:53
@caridy caridy changed the title fix(engine): issue #858 to make setters reactive fix(engine): part of issue #858 to enable the ability to have setters reactive Jun 28, 2019
@caridy caridy changed the title fix(engine): part of issue #858 to enable the ability to have setters reactive fix(engine): issue #858 to enable the ability to have setters reactive Jun 28, 2019
@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: cdc4558 | Target commit: 5e0fa97

lwc-engine-benchmark

table-append-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/append/1k duration 144.90 (±3.90 ms) 137.10 (±4.05 ms) -7.8ms (5.4%) 👍
table-clear-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/clear/1k duration 10.95 (±0.95 ms) 10.00 (±1.10 ms) -0.9ms (8.7%) 👍
table-create-10k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/create/10k duration 856.75 (±5.60 ms) 845.70 (±5.65 ms) -11.0ms (1.3%) 👍
table-create-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/create/1k duration 107.50 (±3.15 ms) 106.20 (±2.80 ms) -1.3ms (1.2%) 👌
table-update-10th-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/update-10th/1k duration 75.35 (±5.70 ms) 68.60 (±2.55 ms) -6.8ms (9.0%) 👍
tablecmp-append-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/append/1k duration 228.70 (±13.35 ms) 223.95 (±13.45 ms) -4.8ms (2.1%) 👌
tablecmp-clear-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/clear/1k duration 7.30 (±1.05 ms) 6.25 (±1.15 ms) -1.0ms (14.4%) 👍
tablecmp-create-10k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/create/10k duration 1603.10 (±10.60 ms) 1643.05 (±25.10 ms) +40.0ms (2.5%) 👎
tablecmp-create-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/create/1k duration 184.70 (±4.10 ms) 188.55 (±3.90 ms) +3.9ms (2.1%) 👎
tablecmp-update-10th-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/update-10th/1k duration 68.00 (±5.35 ms) 65.30 (±5.75 ms) -2.7ms (4.0%) 👌
wc-append-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/append/1k duration 227.75 (±8.70 ms) 233.25 (±11.65 ms) +5.5ms (2.4%) 👎
wc-clear-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/clear/1k duration 11.80 (±1.80 ms) 10.50 (±1.90 ms) -1.3ms (11.0%) 👍
wc-create-10k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/create/10k duration 1874.90 (±11.30 ms) 1883.90 (±14.05 ms) +9.0ms (0.5%) 👎
wc-create-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/create/1k duration 224.65 (±4.60 ms) 225.95 (±5.45 ms) +1.3ms (0.6%) 👌
wc-update-10th-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/update-10th/1k duration 67.90 (±5.55 ms) 66.80 (±4.65 ms) -1.1ms (1.6%) 👌

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: cdc4558 | Target commit: 5e0fa97

lwc-engine-benchmark

table-append-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/append/1k duration 144.90 (±3.90 ms) 138.70 (±3.80 ms) -6.2ms (4.3%) 👍
table-clear-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/clear/1k duration 10.95 (±0.95 ms) 10.35 (±1.15 ms) -0.6ms (5.5%) 👌
table-create-10k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/create/10k duration 856.75 (±5.60 ms) 846.95 (±5.05 ms) -9.8ms (1.1%) 👍
table-create-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/create/1k duration 107.50 (±3.15 ms) 107.40 (±3.40 ms) -0.1ms (0.1%) 👌
table-update-10th-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table/update-10th/1k duration 75.35 (±5.70 ms) 68.80 (±2.90 ms) -6.5ms (8.7%) 👍
tablecmp-append-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/append/1k duration 228.70 (±13.35 ms) 222.50 (±12.80 ms) -6.2ms (2.7%) 👍
tablecmp-clear-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/clear/1k duration 7.30 (±1.05 ms) 6.20 (±0.95 ms) -1.1ms (15.1%) 👍
tablecmp-create-10k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/create/10k duration 1603.10 (±10.60 ms) 1629.35 (±8.85 ms) +26.3ms (1.6%) 👎
tablecmp-create-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/create/1k duration 184.70 (±4.10 ms) 186.70 (±5.05 ms) +2.0ms (1.1%) 👌
tablecmp-update-10th-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-component/update-10th/1k duration 68.00 (±5.35 ms) 67.40 (±5.70 ms) -0.6ms (0.9%) 👌
wc-append-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/append/1k duration 227.75 (±8.70 ms) 231.90 (±11.15 ms) +4.1ms (1.8%) 👌
wc-clear-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/clear/1k duration 11.80 (±1.80 ms) 10.80 (±1.60 ms) -1.0ms (8.5%) 👌
wc-create-10k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/create/10k duration 1874.90 (±11.30 ms) 1854.20 (±13.20 ms) -20.7ms (1.1%) 👍
wc-create-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/create/1k duration 224.65 (±4.60 ms) 228.90 (±4.75 ms) +4.3ms (1.9%) 👎
wc-update-10th-1k metric base(cdc4558) target(5e0fa97) trend
benchmark-table-wc/update-10th/1k duration 67.90 (±5.55 ms) 66.80 (±3.25 ms) -1.1ms (1.6%) 👌

@caridy caridy merged commit c270594 into master Jun 28, 2019
@ekashida ekashida deleted the caridy/issue-858/reactive-setter branch June 28, 2019 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants