content-collections: duplicate documents getting generated on save

Hi there 👋 Thanks for the amazing library - it saves my day! 🥳

I’m having this weird issue I can’t understand how to debug properly. I am using Next.js with the appropriate setup. I have a collection and it works like a charm when I start the next app for the first time. I see my collection of files and they render on the front page properly.

But then I go and just save one of my files again. Regardless if I make changes or not. Then I have my file duplicated inside the collection. Here’s the output (which is also weird):

# here I've hit ctrl+s inside my content-collections.ts
... config changed
build started ...
... finished build of 1 collection and 9 documents in 6ms
# all good so far

# here I hit ctrl+s inside file1.json, without making any changes
... file src\content\file1.json changed
build started ...
... finished build of 1 collection and 10 documents in 5ms
# somehow documents got 10, even though I haven't created another file

# weirdly enough, if I hit ctrl+s again (second time), two events get fired:
... file src\content\file1.json changed
build started ...
... finished build of 1 collection and 10 documents in 5ms
... file src\content\file1.json changed
build started ...
... finished build of 1 collection and 10 documents in 5ms

# hitting ctrl+s more times results in just two events getting fired..

# but if I ctrl+save my content-collections.ts again, I see this:
... config changed
build started ...
... finished build of 1 collection and 9 documents in 7ms

I’m seeing this on Windows 11, TS 5.6.3, with this following project setup:

"devDependencies": {
  "@content-collections/core": "^0.7.2",
  "@content-collections/next": "^0.2.3",
  "@types/node": "^20",
  "@types/react": "^18",
  "@types/react-dom": "^18",
  "eslint": "^8",
  "eslint-config-next": "15.0.1",
  "postcss": "^8",
  "tailwindcss": "^3.4.1",
  "typescript": "^5"
}

Any ideas on how to troubleshoot it further? I’ll probably clone the repo tomorrow and play with it, but I’d appreciate any hints upfront 😉

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

The fix is now released with version 0.7.3 of @content-collections/core