Conversation
Vue 3 invokes app.config.errorHandler with a null instance for errors raised outside a component context; the handler crashed on it and lost the original error. Component name resolution also never worked for Options API SFCs without an explicit name: the $vnode branch is Vue 2 API and __name only exists for <script setup> components. Fall back to the basename of $options.__file, set by vue-loader (in production builds only when its exposeFilename option is enabled). Fixes appsignal#678 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #678.
Two fixes to the
@appsignal/vueerror handler when used with Vue 3:Null instance crash. Vue 3 invokes
app.config.errorHandler(err, instance, info)withinstance: nullfor errors raised outside a component context (e.g. in watchers, or lifecycle hooks after unmount). The handler dereferenced the instance unguarded and threw aTypeErrorof its own, so the original error never reached AppSignal orconsole.error. It now reports these as[unknown Vue component].Component name resolution on Vue 3. The
$vnodebranch is Vue 2 API (alwaysundefinedon Vue 3),$options.namerequires an explicitnameoption, and__nameonly exists for<script setup>components. For classic Options API SFCs none of these match, so every error grouped under[unknown Vue component]. The handler now falls back to the basename of$options.__file, which vue-loader sets in development and, when the app enables itsexposeFilenameoption, as a basename in production builds. When__fileis absent the existing[unknown Vue component]fallback is preserved, so behaviour only changes for apps that opt in.Includes a mono changeset (
bump: patch,type: fix) and test coverage for the new branches:__filewith a full path (development), basename-only__file(production), explicitnametaking precedence, a null instance, and empty options. Verified locally withjestinpackages/vue(8 passing) andprettier --check.