Skip to content

Better to remove getFn in keys when calling FuseIndex.toJSON #798

Closed as not planned

Description

@bin16

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

FuseIndex<T>.toJSON() keeps getFn in keys, as a result, the returned object can not be write to IndexedDB directly because of the following error:

DataCloneError: Function object could not be cloned.

Considering that functions in object will be removed when calling JSON.stringify(), the getFn function seems do nothing when parseIndex later. So I think it may be better to just remove it when calling FuseIndex.toJSON.


Besides, there's no v7.1.0 in The Fuse.js version where this bug is happening.* of issue form.

The Fuse.js version where this bug is happening.

Other (please specify in description)

Is this a regression?

  • This is a regression bug

Which version did this behavior use to work in?

None

Steps To Reproduce

  1. create index with some keys have getFn
  2. write the index to IndexedDB

Expected behavior

  1. no getFn in keys of FuseIndex<T>.toJSON's result.

Screenshots

No response

Additional context

No response

Activity

  1. changed the title [-]FuseIndex.toJSON wrong type of keys ReadonlyArray<string>; also may be better to remove getFn when toJSON[/-] [+]Better to remove getFn in keys when calling FuseIndex.toJSON[/+] on Apr 9, 2025
  2. bin16 commented on Apr 9, 2025

    @bin16
    Author

    Oh sorry, there's already another issue reports ReadonlyArray<string> problem. Let's just focus on the advice of removing getFn when calling toJSON.

    Title edited, but i can not edit tags.

  3. github-actions commented on Aug 8, 2025

    @github-actions

    This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days

  4. added 2 commits that reference this issue on Apr 2, 2026
    0f2a69b
    c0aa7d1
  5. krisk commented on Apr 2, 2026

    @krisk
    Owner

    Fixed in 0f2a69b. toJSON() now strips getFn from keys, so the result is safe for structuredClone, IndexedDB, JSON.stringify, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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