Identical calls to matter should produce the same result #124

Open
opened 2021-05-30 14:52:20 +00:00 by movermeyer · 1 comment
movermeyer commented 2021-05-30 14:52:20 +00:00 (Migrated from github.com)

Identical, successive calls to matter return different results.

Example code:

const input = `---
foo: bar
---
Tada!`;

const parsed = matter(contents);
const parsed_again = matter(contents);
console.log(parsed.language) // => yaml
console.log(parsed_again.language) // => undefined

I understand from this comment that it's caching based on the input string, and I can cache bust by passing in an empty options hash as a workaround.

In this case, I'm fine with it caching (even though it was unexpected and IMO should at least be documented). However, the cache should cache the resulting object exactly, so that identical calls to matter always return the same result.

Identical, successive calls to `matter` return different results. Example code: ```typescript const input = `--- foo: bar --- Tada!`; const parsed = matter(contents); const parsed_again = matter(contents); console.log(parsed.language) // => yaml console.log(parsed_again.language) // => undefined ``` I understand from [this comment](https://github.com/jonschlinkert/gray-matter/issues/43#issuecomment-318250090) that it's caching based on the input string, and I can cache bust by passing in an empty options hash as a workaround. In this case, I'm fine with it caching (even though it was unexpected and IMO [should at least be documented](https://github.com/jonschlinkert/gray-matter/issues/106)). However, the cache should cache the resulting object exactly, so that identical calls to `matter` always return the same result.
olayway commented 2024-06-27 11:37:39 +00:00 (Migrated from github.com)

It's seems that the results are cached based on the content after frontmatter only, and not the whole content string. Which is even weirder. This means that when it first parses this:

# Some title

Some content

it will return {}, but when it then parses this:

---
abc: 123
---
# Some title

Some content

it returns cached {}...

It's seems that the results are cached based on the content **after** frontmatter only, and not the whole content string. Which is even weirder. This means that when it first parses this: ```md # Some title Some content ``` it will return `{}`, but when it then parses this: ```md --- abc: 123 --- # Some title Some content ``` it returns cached `{}`...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rtlabs-llm-agents/gms-gray-matter#124
No description provided.