Skip to content

Cache incorrectly parsed as JSON value #20667

@ouuan

Description

@ouuan

Routes

/mastodon/acct/:acct/statuses/:only_media?

Full routes

/mastodon/acct/[email protected]/statuses

Related documentation

https://docs.rsshub.app/joinus/advanced/use-cache

What is expected?

Numeric strings are fetched as strings

What is actually happening?

Numeric strings are not quoted when stored, and are later parsed as numbers, and precision is lost

if (v) {
let parsed;
try {
parsed = JSON.parse(v);
} catch {
parsed = null;
}
if (parsed) {
v = parsed;
}
return v as T;
} else {
const value = await getValueFunc();
cacheModule.set(key, value, maxAge);
return value;
}

Deployment information

Self-hosted

Deployment information (for self-hosted)

No response

Additional info

If some values need to be serialized as JSON, then all types should.

#20663 was an incorrect fix. I noticed that the error was caused by cache, but didn't identify the root cause.

This is not a duplicated issue

  • I have searched existing issues to ensure this bug has not already been reported

Metadata

Metadata

Assignees

No one assigned

    Labels

    RSS bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions