topaxi / ember-shoebox-decorator

A decorator for the Ember FastBoot shoebox.
MIT License
10 stars 0 forks source link

JSON conversion error with store.findAll #1

Open nickschot opened 7 years ago

nickschot commented 7 years ago

A model hook as follows:

@shoeboxModel
model(){
    return this.store.findAll('post');
}

results in a JSON parsing error. I get this when using ember-data + fastboot + ember-ajax. This is likely because the ember model instance has a circular reference of some kind.

Might be related to: https://github.com/ember-fastboot/fastboot/issues/99

Stacktrace:

TypeError: Converting circular structure to JSON
  at JSON.stringify (<anonymous>)
  at createShoebox (/ember-fastboot-test/node_modules/fastboot/src/ember-app.js:456:26)
  at visitRoute.then (/ember-fastboot-test/node_modules/fastboot/src/ember-app.js:325:11)
  at tryCatch (/ember-fastboot-test/tmp/broccoli_merge_trees-output_path-Zr7UN3Cf.tmp/assets/rsvp.js:411:1)
  at invokeCallback (/ember-fastboot-test/tmp/broccoli_merge_trees-output_path-Zr7UN3Cf.tmp/assets/rsvp.js:424:1)
  at publish (/ember-fastboot-test/tmp/broccoli_merge_trees-output_path-Zr7UN3Cf.tmp/assets/rsvp.js:394:1)
  at /ember-fastboot-test/tmp/broccoli_merge_trees-output_path-Zr7UN3Cf.tmp/assets/ember-testing/ext/rsvp.js:14:1
  at invokeWithOnError (/ember-fastboot-test/tmp/broccoli_merge_trees-output_path-Zr7UN3Cf.tmp/assets/backburner.js:283:1)
  at Queue.flush (/ember-fastboot-test/tmp/broccoli_merge_trees-output_path-Zr7UN3Cf.tmp/assets/backburner.js:153:1)
  at DeferredActionQueues.flush (/ember-fastboot-test/tmp/broccoli_merge_trees-output_path-Zr7UN3Cf.tmp/assets/backburner.js:345:1)
topaxi commented 7 years ago

Yeah this is not going to work with Ember Data, I should probably mention this in the README.md.

Ember Data would need more logic like pushing the original response into the store.

nickschot commented 7 years ago

That'll work for me! A note in the README would be good indeed.

Workaround which currently works for ember-data: https://github.com/Appchance/ember-cached-shoe