emberjs / emberjs/ember.js

[Bug] createCache + HelperManager args are recycled upon update, meaning there is no way to access previous args?

Open
#19,758 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

### 🐞 Describe the Bug

I have a resource implementation that passes the previous instance of a resource to the next instance of a resource, but the args are the same in both resources. My hunch is that there is either a bug in the HelperManager I've made, or I don't understand something about the HelperManager (maybe likely?).

### 🔬 Minimal Reproduction
1. clone this branch: https://github.com/NullVoxPopuli/ember-resources/pull/196/files#diff-2dc1fb4dff6d6d3ac74f7f727755ef3bd0dcb32373b3d40c6c896a3a577e4802R57
2. start the tests
3. open the console
4. visit: http://localhost:4200/tests?hidepassed&testId=888d27c7

Observe that:
![image](https://user-images.githubusercontent.com/199018/134063729-b6c3fc02-84e7-4dfe-865d-fcc8db6d47b3.png)

### 😕 Actual Behavior
createCache's previous instance's args have the same values as the current instance's args.

The only work around I can think of is to consume all args eagerly in `createCache` and set `args` to a vanilla object, rather than the tracked proxy / thunk that args currently are.

### 🤔 Expected Behavior
The previous instance's args are unchanged

### 🌍 Environment

- Ember: - 3.25+
- Node.js/npm: - n/a
- OS: - n/a
- Browser: - n/a

### ➕ Additional Context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.