Skip to content

Blob and File Obj check would not work in Mini-Program enviroment #1555

Closed

Description

@CornWorld

Report a bug

🔎 Search Terms

Arktype in Wechat Mini program

🧩 Context

  • ArkType version: 2.1.27
  • TypeScript version (5.1+):5.9.3
  • Other context you think may be relevant (JS flavor, OS, etc.):
    System:
    OS: macOS 15.6.1
    CPU: (16) x64 Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
    Memory: 2.05 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
    Binaries:
    Node: 22.16.0 - /Users/corn/.nvm/versions/node/v22.16.0/bin/node
    npm: 10.9.2 - /Users/corn/.nvm/versions/node/v22.16.0/bin/npm
    pnpm: 10.12.1 - /Users/corn/.nvm/versions/node/v22.16.0/bin/pnpm
    npmPackages:
    arktype: ^2.1.27 => 2.1.27
    typescript: ^5.9.3 => 5.9.3

🧑‍💻 Repro

  1. Create an new project in Miniprogram Devtools
  2. Exec pnpm i arktype
  3. Add code like below:
import { type } from 'arktype';

const FlowItem = type({
    'source?': 'string|number',
    'update_time?': 'string|number',
    'value?': 'unknown',
});
  1. Report like ReferenceError: Blob is not defined from @ark/utils 's check. I see a lot of object checking in this pack, like:
    Array,
    Boolean,
    Blob,
    Date,
    Error,
    Function,
    Map,
    Number,
    Promise,
    RegExp,
    Set,
    String,
    WeakMap,
    WeakSet,
    ArrayBuffer,
    Blob,
    File,
    FormData,
    Headers,
    Request,
    Response,
    URL,
    Int8Array,
    Uint8Array,
    Uint8ClampedArray,
    Int16Array,
    Uint16Array,
    Int32Array,
    Uint32Array,
    Float32Array,
    Float64Array,
    BigInt64Array,
    BigUint64Array,

Are those all necessary to arktype or just injected by bundle tools? Shall you warp those errors to make it work?

Activity

  1. CornWorld commented on Nov 26, 2025

    @CornWorld
    Author

    I've already located the code at

    File: FileConstructor,
    , and notice your comment in code "Must be implemented in Node etc. as well as the browser to include here".
    Why not add a check or add a getter func to safely access those object or throw something more helpful? The error like ReferenceError: Blob is not defined would not tell anybody the info like "MUST BE IMPLEMENTED" or the requirement list.

  2. Andonvr commented on Dec 25, 2025

    @Andonvr

    This is also an issue for me: I can't use Arktype inside a worker, in my case an audio worklet processor.
    I was planning on using Arktype for validating messages to and from the worker. I'll use Zod instead for now, and ArkType for other usecases (maybe a wise choice here, as bundle size could be relevant for workers?)

  3. CornWorld commented on Dec 27, 2025

    @CornWorld
    Author

    This is also an issue for me: I can't use Arktype inside a worker, in my case an audio worklet processor. I was planning on using Arktype for validating messages to and from the worker. I'll use Zod instead for now, and ArkType for other usecases (maybe a wise choice here, as bundle size could be relevant for workers?)

    Oh, for bundle size, Arktype may be a great lib to use. You can mock all the Object the Arktype use to skip the error.
    TIP: Zod and Arktype all get JIT features which depend on new Function(...) JS feautre. Close them in some non-browser env to avoid troubles.
    @Andonvr

  4. guyutongxue commented on Apr 7, 2026

    @guyutongxue

    +1 here, when I embed my application code inside a raw V8/QuickJS engine, these reference produces error (in module/strict mode). The workaround is to add following statements at the top:

    globalThis.Blob ??= function Blob() {};
    globalThis.FormData ??= function FormData() {};
    globalThis.Headers ??= function Headers() {};
    globalThis.Request ??= function Request() {};
    globalThis.Response ??= function Response() {};
    globalThis.URL ??= function URL() {};
  5. added a commit that references this issue on Oct 13, 2026
    0332e7a
  6. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    Member

    Fixed in 3.0.0-beta.0 (#1728). Try it with npm i arktype@next.

  7. moved this from To do to Done (merged or closed) in arktypeioon Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status
    Done (merged or closed)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions