Skip to content

[Bug?]: 'use server' will cause an error when there is Chinese in the file path #1859

@thinke5

Description

@thinke5

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'headers' property from 'RequestInit': String contains non ISO-8859-1 code point.
    at createRequest (server-runtime.js:94:12)
    at fetchServerFunction (server-runtime.js:119:11)
    at fn (server-runtime.js:175:32)

Expected behavior 🤔

no error

Steps to reproduce 🕹

Steps:

  1. create file src/routes/中文.tsx
import { Title } from '@solidjs/meta';
import { createAsync, query } from '@solidjs/router';
import { createSignal, Suspense } from 'solid-js';

const getInfo = query(async (id: number) => {
  'use server';

  return { id };
}, 'getInfo');

export default function zh() {
  const [uid, setUid] = createSignal(0);
  const info = createAsync(() => getInfo(uid()));

  return (
    <main>
      <Title>中文</Title>
      <h1>id = {uid()}</h1>
      <div class="flex gap-lg ">
        <button onClick={() => setUid((n) => n + 1)}>id+1</button>
        <button onClick={() => setUid((n) => n - 1)}>id-1</button>
      </div>
      <Suspense fallback="loading...">
        <pre>data = {JSON.stringify(info(), null, 1)}</pre>
      </Suspense>
    </main>
  );
}
  1. Visit the corresponding page
  2. click btn id+1

Context 🔦

Because headers does not allow special characters such as Chinese

But in x-server-id there is a full path, Chinese characters will appear

Your environment 🌎

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions