AdvancedImage/AdvancedVideo crash: "Cannot read properties of undefined (reading 'htmlPluginState')" when unmounted before onMounted
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- typescript
- Domínio
- frontend
Direção de pesquisa
Comece pelos hooks onUpdated e onUnmounted em packages/vue/src/components/AdvancedImage.vue nas linhas vinculadas e, em seguida, inspecione os hooks correspondentes em AdvancedVideo. Reproduza o caso de mount-to-unmount rápido descrito na issue e verifique se ambos os componentes não lançam mais exceções quando htmlLayerInstance não estiver disponível.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
New issue for cloudinary/frontend-frameworks
For which package is this issue?
@cloudinary/vue — AdvancedImage / AdvancedVideo.
Describe the issue in a sentence or two.
AdvancedImage and AdvancedVideo read htmlLayerInstance.htmlPluginState in their onUpdated/onUnmounted hooks without a null check. htmlLayerInstance is only assigned in onMounted, so if the component is unmounted before onMounted runs (e.g. a fast route transition / rapid mount→unmount), the onUnmounted hook throws TypeError: Cannot read properties of undefined (reading 'htmlPluginState'). Confirmed still present on master (1.13.4).
Source:
- onUpdated: https://github.com/cloudinary/frontend-frameworks/blob/master/packages/vue/src/components/AdvancedImage.vue#L153-L156
- onUnmounted: https://github.com/cloudinary/frontend-frameworks/blob/master/packages/vue/src/components/AdvancedImage.vue#L161-L164
Suggested fix — guard the instance in both hooks (and in AdvancedVideo):
onUpdated(() => {
if (!htmlLayerInstance) return;
cancelCurrentlyRunningPlugins(htmlLayerInstance.htmlPluginState);
htmlLayerInstance.update(props.cldImg, props.plugins, SDKAnalyticsConstants);
});
onUnmounted(() => {
htmlLayerInstance?.htmlPluginState &&
cancelCurrentlyRunningPlugins(htmlLayerInstance.htmlPluginState);
});
Same class of "missing undefined guard" as #181 (analyticsOptions in HtmlImageLayer).
Issue Type (Can be multiple)
[ ] Build - Can't install or import the SDK
[ ] Performance - Performance issues
[x] Behaviour - Functions aren't working as expected
[ ] Documentation - Inconsistency between the docs and behaviour
[ ] Incorrect Types
[ ] Other (Specify)
Steps to reproduce
- Render
<AdvancedImage :cldImg="..." />(no plugins needed). - Unmount it before mount completes — e.g. toggle it off via
v-ifin the same tick it is created, or navigate away immediately after the route that mounts it. - The
onUnmountedhook throws the TypeError above.
Error screenshots
No screenshot; relevant stack frames:
TypeError: Cannot read properties of undefined (reading 'htmlPluginState')
at hook (@cloudinary/vue/index.js) // onUnmounted
at callWithErrorHandling (@vue/runtime-core)
at callWithAsyncErrorHandling (@vue/runtime-core)
at flushPostFlushCbs (@vue/runtime-core)
at flushJobs (@vue/runtime-core)
Browsers (if issue relates to UI, else ignore)
[ ] Chrome
[ ] Firefox
[ ] Safari
[ ] Other (Specify)
[x] All
Versions and Libraries (fill in the version numbers)
@cloudinary/vue - 1.13.0 (also reproduces on master / 1.13.4)
Node - 22.22.2
NPM - 10.9.7
Config Files (Please paste the following files if possible)
N/A — bug is in the library's lifecycle hooks (source links above).
Repository
No standalone repro repo; the issue is in the component lifecycle hooks linked above.
- Linguagem predominante
- TypeScript
- Estrelas
- 49
- Forks
- 17
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de cloudinary/frontend-frameworks
-
HTML Depends on TypeScriptAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 42/100
cloudinary/frontend-frameworks#253 · 5 comentários ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
cloudinary/frontend-frameworks#240 · 1 comentário · 1 reação ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 38/100
cloudinary/frontend-frameworks#234 · 20 comentários · 1 reação ·
Todas as issues de cloudinary/frontend-frameworks
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
devswha/herdr-web-ui#3875 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
-
area: runtime chore cli consistency dependencies developer-experience difficulty: easy discovery documentation enhancement good first issue help wanted hygiene json-output packaging priority: P3 tests version
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
discovery:other factory-active task-identify-harness-labels-done task-identify-issue-type-done
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
vercel/ai#25068 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
create-strapi-app doesn't await writing license.txt, so a failed write skips its error handlingAbertaflag: invalid template issue: bug severity: low source: cli status: pending reproduction version: 5
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
strapi/strapi#28637 · 1 comentário ·
Mantenedores costumam responder em até 2 dias