Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RouteAction returns undefined in case of error #927

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

frenzzy
Copy link
Contributor

@frenzzy frenzzy commented Jul 6, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • infrastructure changes
  • TypeScript typings

What is the current behavior?

In case of error createServerAction$ returns undefined as a result, but typings don't:

import { FormError } from 'solid-start'
import { createServerAction$ } from 'solid-start/server'

export default function Page() {
  const [action, submit] = createServerAction$(async (formData: FormData) => {
    if (formData.get('hasError')) {
      throw new FormError('Validation failed')
    }
    return 'demo'
  })
  return (
    <submit.Form
      onsubmit={async (event) => {
        event.preventDefault()
        const formData = new FormData(event.currentTarget)
        const result = await submit(formData)
        console.log(action.result === result) // true
        console.log(action.result) // type: string | undefined
        /* ACTUAL:   */ console.log(result) // type: string
        /* EXPECTED: */ console.log(result) // type: string | undefined
      }}
    >
      <input type="checkbox" name="hasError" value="yes" />
      <input type="submit"/>
    </submit.Form>
  )
}

What is the new behavior?

Typings reflect the actual behavior

Other information

@ryansolid ryansolid merged commit 3f9961b into solidjs:main Jul 19, 2023
@ryansolid
Copy link
Member

Thanks

ryansolid added a commit that referenced this pull request Aug 8, 2023
* feat: internal-fetch more powerful

* fix (scss): fix scss/sass support for dev inline styles

* add example movies

* example(movies): add more routes for /movie and /tv

* example(movies): add more pages

* movies demo

* fix(islands): css, prefetching, default A island

* enable islands for app

* clean up logging

* fix movies

* bug fix: nested routing in islands server router

* css assets for islands router

* feat: persisted islands!!

* experiment: updated movies app to use folder-based routing

* app layout as layout.tsx

* remove logging

* layout support

* movies example: use folder based routing

* Added PersonInfo and ExternalLinks components

* Removed v tags from vue and added conditional renderings of elements

* Added in conditional to not render ListingCarousel if items does not have length

* Added debounce to the search for movies

* Added more details and formatting to MovieInfo and Hero

* Removed stray console.log

* cleanup

* move PersonInfo inside route  and use unplugin icons

* example(movies): fix external links and image sizes

* movies: fix styles scss import

* fix some implementation details for islands

* workers adapter seed function

* notes with server-components demo

* example(notes): remove delay

* only preload used islands

* examples(note): move components to directory

* fix: navigate not changing url state

* example(movies): fix search param feature

* a fix

* notes example update

* experimental islands mutation

* multiple JSX slots

* islands -> server components

* islands -> example

* fix

* Created Poster component to add 3d effect to Posters

* Fix splitProps

* Update islands path from env manifest. Update vite plugin transform and load functions for islands.

* Add solid logo to nav bar.

* fix islands build with use client

* add dark mode toggle

* notes example cleanup

* cleanup client components

* Added Netlify adapter

* Remove workspace reference

* export things from root properly

* fix server-routing, use partial rendering on the server

* fix movie example

* Small css improvements

* Update paths for island transforms in vite plugin in dev mode.

* Update paths for island references in islandsManifest generation in bin.cjs.

* Add images to movies details page.

* fix stuff

* fix auto detect adapter for now

* clean up logs

* clean up data fetching

* fix route actions

* fix merge

* fix islands

* mounting fix

* fix islands inside islands

* prisma example

* package json fixes

* Update broken paths on Windows in dev mode. Add missing if statement in internalFetch. Change server-router to use useRequest instead of useServerContext.

* fix typescript and new durable object API

* fix notes durable object example

* migrate notes to server components

* in progress: fix types (cloudlfare durable objects are fucked up)

* typescript jump and bug fixes

* ignore vite compiled configs

* ssr configurable with `render` entry

* islands type fixes

* notes

* cleanup manifest code

* fix islands router

* fix islands stuff

* remove nprogress

* fix adapters

* better images for movies demo

* setup for streaming, fix accessibility

* add back loading indicator

* small tweak to loader

* movies updates

* fix dev and build

* fix DEBUG

* fix tests

* fix SPA client build failing because of whitespace in path (#926)

* RouteAction returns undefined in case of error (#927)

* docs/fix-trpc-example (#931)

Co-authored-by: Ryan Carniato <[email protected]>

* Update createRouteAction.md (#939)

yer I love open source

* fix(data): update Form types in createRouteAction.tsx (#936)

Co-authored-by: Ryan Carniato <[email protected]>

* 0.2.27

* remove layout support

* remove more layouts

* fix lock

* fix bad merge on server functions

* fix notes demo

* bump example versions

* fix types

* possibly temp fix for tests until find better solution

* try deno specific internalFetch

* better deno fix

* fix missing reference

* fix internalFetch

* fixup cloudflare internalFetch

* add cloudflare internal fetch early exit

* update Solid to 1.7.9 (fix movies demo)

* normalize entries, fix docs

* fix docs build errors

---------

Co-authored-by: Nikhil Saraf <[email protected]>
Co-authored-by: Maxi Ferreira <[email protected]>
Co-authored-by: TannerScadden <[email protected]>
Co-authored-by: Muhammad Zaki <[email protected]>
Co-authored-by: Paolo Ricciuti <[email protected]>
Co-authored-by: dev-rb <[email protected]>
Co-authored-by: David Di Biase <[email protected]>
Co-authored-by: Davide <[email protected]>
Co-authored-by: Vladimir Kutepov <[email protected]>
Co-authored-by: Jordan Gibbings <[email protected]>
Co-authored-by: Felix Zeller <[email protected]>
Co-authored-by: Casey Baggz <[email protected]>
@frenzzy frenzzy deleted the patch-2 branch December 30, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants