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
- fix(core): #373 make external logic work with absolute path on windows — committed to sdorra/content-collections by sdorra 2 years ago
- fix(core): #373 do not include directory separator in assertion — committed to sdorra/content-collections by sdorra 2 years ago
- fix(core): #373 watcher tests are flaky on windows, so we retry them — committed to sdorra/content-collections by sdorra 2 years ago
- fix(core): #373 changes in a sub directory are treated as new on win32 The globbing library used (tinyglobby) always returns paths with POSIX separators. This creates problems when a path is generate... — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 run tests on windows and linux — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 do not use cached tests on other os — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 continue other builds if one fails — committed to sdorra/content-collections by sdorra 2 years ago
- chore: #373 use same eol on git, editorconfig and prettier — committed to sdorra/content-collections by sdorra 2 years ago
- ci(core): #373 increase timeout and retries for watcher tests Increase the timeout for waitUntil to 5 seconds and increase the retries from 3 to 5 in order to make the tests pass on the Windows CI se... — committed to sdorra/content-collections by sdorra 2 years ago
- test(core): #373 remove tests with mocked directory separator We now run CI tests on Windows, so we no longer need the mocked path tests. — committed to sdorra/content-collections by sdorra 2 years ago
- ci(core): #373 skip failing watcher tests on windows — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 cache playwright browser to speed up ci — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 cache playwright browser to speed up ci — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 install only chromium — committed to sdorra/content-collections by sdorra 2 years ago
- fix(core): #373 make external logic work with absolute path on windows — committed to sdorra/content-collections by sdorra 2 years ago
- fix(core): #373 do not include directory separator in assertion — committed to sdorra/content-collections by sdorra 2 years ago
- fix(core): #373 watcher tests are flaky on windows, so we retry them — committed to sdorra/content-collections by sdorra 2 years ago
- fix(core): #373 changes in a sub directory are treated as new on win32 The globbing library used (tinyglobby) always returns paths with POSIX separators. This creates problems when a path is generate... — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 run tests on windows and linux — committed to sdorra/content-collections by sdorra 2 years ago
- ci: #373 do not use cached tests on other os — committed to sdorra/content-collections by sdorra 2 years ago
The fix is now released with version 0.7.3 of
@content-collections/core