Skip to content

Server-side Toasts with a redirect creates a JS error #14797

Description

@martyf

Bug description

I have a simple NavItem in my CP that just calls the route: the route does something, sends a "success" toast, and returns:

publicfunction__invoke()
{
// do some things
Toast::success('Success!');
return Inertia::back();
}

However, a JS error is thrown, and an empty array is send back as the Toast, resulting in the console error:

Uncaught TypeError: this[type] is not a function

The props for _toasts looks like:

{
"_toasts": [
[]
]
}

How to reproduce

  1. Create a new Statamic site
  2. Create a simple CP controller (Controller file, and the route), and use the __invoke method above
  3. Add a Nav item via the AddonServiceProvider
  4. Visit the route in the CP

Logs

Environment

EnvironmentLaravel Version: 13.14.0PHP Version: 8.4.22Composer Version: 2.9.5Environment: localDebug Mode: ENABLEDMaintenance Mode: OFFTimezone: UTCLocale: enCacheConfig: NOT CACHEDEvents: NOT CACHEDRoutes: NOT CACHEDViews: CACHEDDriversBroadcasting: logCache: fileDatabase: sqliteLogs: stack / singleMail: logQueue: syncSession: fileStoragepublic/storage: NOT LINKEDLivewireLivewire: v4.3.1StatamicAddons: 0License Key: Not setSites: 1Stache Watcher: Enabled (auto)Static Caching: DisabledVersion: 6.20.2 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions