instantsearch: Nuxt dev server hangs when using `findResultsState` with children routes
Bug 🐞
I have an odd issue when using Nuxt, SSR, and vue-instantsearch. Following this guide, I’ve made a stripped down demo repo of the bug in question (I’ve confirmed that the issue is happening with a fresh git pull
, yarn
and yarn dev
of that repo).
It simply seems that some combination of using this.instantsearch.findResultsState
in serverPrefetch
and having a <router-view />
or <NuxtChild />
in the same component causes the dev server to eat a bunch of memory and eventually crash. Sometimes an event emitter error is printed to the dev server console. Aside from that, not much to go on.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 16 (7 by maintainers)
Commits related to this issue
- fix(ssr): use dedicated instance per render fixes #1114 — committed to algolia/vue-instantsearch by Haroenv 2 years ago
- fix(ssr): use dedicated instance per render fixes #1114 — committed to algolia/vue-instantsearch by Haroenv 2 years ago
Hello @Haroenv,
With Nuxt 2, I was also having memory leak issues. Using Siege, I was doing user simulation of 40 request in 30 seconds, and each time memory was increasing.
However, algolia/vue-instantsearch#1115 did fix the issue.
After building the library with algolia/vue-instantsearch#1115 , I was getting a constant 70mb usage which was not increasing in memory even after 120 request in 60 seconds.
algolia/vue-instantsearch#1117 did not fix the “TypeError: Cannot set property $nuxt of [object Object] which has only a getter” on my side. What I did to fix this was change a boolean on line 115 in createServerRootMixin, from true to false.
const isWritable = descriptor ? descriptor.writable || descriptor.set : false;
In Nuxt 2, descriptor is undefined, so I just made sure “isWritable” is set to false.
@Haroenv i tried it and it does not solve the issue.
Thanks! I’ll schedule to take a look tomorrow!
The error indeed occurs with https://github.com/algolia/vue-instantsearch/tree/master/examples/nuxt - though I cheated by using
"vue-instantsearch": "4.3.3",
in mypackage.json
after gettingCouldn't resolve vue-instantsearch
errors.This time it also spit out that EventEmitter error:
ERROR (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit
The error definitely mucks up my local ports on my machine as well. Every time I restart the dev server, it picks a progressively higher port, as the previous one is still in use, as the server didn’t clean up properly.
I’ll try the other repo as well (any tips on how to fix the
Can't resolve vue-instantsearch
errors?).EDIT: It happens with the doc-code-samples repo as well. Everything works as expected, but as soon as I put a
<router-view />
insearch.vue
, the dev server hangs.My current node version is
v14.18.2
.