[Regression] Loaded note metadata is overwritten with an empty object, causing note titles to disappear
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, react
- Domínio
- frontend
Direção de pesquisa
The bug sits in the note settings state path: useNoteSetting() in index-BArqKHpl.js falls back to an empty object when useNoteMetaSettingQuery() returns nothing, and NoteSettingsModal-Me4Fdoz4.js then writes that into the shared appState proxy (metadata and metadataLoaded). Start by reading those three functions and the appState setter, then find why the query briefly returns no data. Done means previously loaded metadata survives a transient empty result and the browser title stays put across a re-render.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Is this a hackmd.io issue?
- Yes, the bug happens on https://hackmd.io/
- No. If it's a self-hosted CodiMD instance, please fire up the issue in the repo of CodiMD: https://github.com/hackmdio/codimd
Read our Official tutorial
It's on https://hackmd.io/c/tutorials/
或是中文版 https://hackmd.io/c/tutorials-tw/
What's the problem
Current behaviour
Recently, I have been experiencing an intermittent issue where note titles disappear:
- The browser tab title reverts to the default HackMD site title.
- The note title within the editor becomes "Untitled".
- Reloading the page restores the correct title.
- This issue occurs across multiple existing notes.
I started noticing this regression around the November 2026 update.
Steps to reproduce
- Open an existing note with a valid title.
- Continue using HackMD normally.
- Eventually, the browser tab title reverts to the default HackMD site title, and the note title within the editor becomes "Untitled".
- Reload the page and observe that the correct title is restored.
I have not yet identified a deterministic sequence of user actions that triggers this issue. However, I have successfully reproduced and captured the underlying metadata overwrite using Chrome DevTools, as described below.
The issue does not appear to depend on the Markdown content of a particular note.
Expected behaviour
- The browser tab and editor should consistently display the correct note title.
- Previously loaded metadata for the same note should not be overwritten with an empty object while new metadata is unavailable or still loading.
- Users should not need to reload the page to restore the correct title.
Environment
I use HackMD on:
Desktop
- OS: macOS (Apple Silicon)
- Browser: Google Chrome
- Browser Version: 158.0.8127.89 (Official Build) (arm64)
- Reproduced on: November 24, 2026
- Tampermonkey: Disabled during the final reproduction test
Mobile
- Not tested.
Additional context
1. Technical investigation
I investigated this issue using Chrome DevTools and identified a code path where previously loaded note metadata is overwritten with an empty object.
In index-BArqKHpl.js, useNoteSetting() falls back to an empty object when metadata query data is unavailable:
function useNoteSetting(e, t) {
let [n, r] = useNoteMetaSettingQuery(e);
let i = n || {};
let a = {
values: i,
// ...
loaded: r && n === i
};
// ...
return a;
}
In NoteSettingsModal-Me4Fdoz4.js, the returned values are obtained as follows:
let {
values: n,
actions: r,
loaded: i
} = x(Ye, e.markdownParser);
These values are then propagated to the global application state:
h = () => {
st.metadata = n;
st.metadataLoaded = i;
st.forceUpdateView();
}
There appears to be no guard preventing unloaded metadata from overwriting previously loaded metadata.
2. State update and notification
In appState-PB6khxMh.js, the Proxy setter synchronously notifies subscribers after updating a property:
set(e, t, n) {
return e[t] = n,
X.forEach(r => r(e, t, n)),
true;
}
In frontend-BAkmRvza.js, a subscriber triggers the browser title update whenever the metadata changes:
Mr((e, t) => {
t === "metadata" && I5()
})
The title update ultimately retrieves the note title through the following function in extra-Dypugcex.js:
function Bm(e) {
return q.metadata?.title || null;
}
If the title is unavailable, the browser tab title falls back to the default HackMD site title.
3. Debugging evidence
I placed a conditional breakpoint immediately before the assignment in the application state Proxy setter:
t === "metadata" && !!e[t]?.title && !n?.title
With Tampermonkey disabled, the breakpoint was triggered, and I captured the following values before the assignment:
{
previousTitle: "<valid note title>",
previousLoaded: true,
previousKeys: [
"title",
"bookRenderer",
"description",
"contributors",
"breaks"
],
incomingTitle: undefined,
incomingKeys: [],
visibility: "visible",
timestamp: "2026-11-24T09:02:11.559Z"
}
This confirms that previously loaded metadata containing a valid title and four other properties is about to be replaced with an empty object.
In an earlier debugging session, I also captured the following values inside the NoteSettingsModal callback, after the metadata assignment but before the metadataLoaded assignment:
{
metadataKeys: [],
incomingTitle: undefined,
incomingMetadataLoaded: false,
currentMetadataLoaded: true,
currentTitle: undefined,
sameObject: true
}
The browser title computation returned:
{
currentTitle: "<valid note title> - HackMD",
computedTitle: "HackMD - Markdownで知識ベースを共作",
loaded: true,
J7: false,
visibility: "visible"
}
After resuming JavaScript execution in that session, the browser tab title reverted to the default HackMD site title, and the editor displayed "Untitled".
4. Call stack
The captured call stack was:
I5 frontend-BAkmRvza.js:703
(anonymous) frontend-BAkmRvza.js:711
(anonymous) appState-PB6khxMh.js:1
set appState-PB6khxMh.js:1
h NoteSettingsModal-Me4Fdoz4.js:3
[React internal frames]
5. Possible cause and suggested direction
Based on the above investigation, there appear to be two issues:
- An unloaded metadata result can overwrite previously loaded metadata with an empty object.
metadataandmetadataLoadedare updated separately, allowing subscribers to observe an inconsistent intermediate state.
Consider preserving previously loaded metadata while new metadata for the same note is unavailable or still loading.
It may also be worth reviewing whether these two properties should be updated atomically before notifying subscribers.
I have not yet identified why useNoteMetaSettingQuery() temporarily returns unavailable data.
Although multiple metadata properties are cleared from the client-side application state, I have not observed any evidence of persistent server-side data loss.
6. Related issues
- #418
- #446
I have also been experiencing the title renaming issue described in #418 and #446 on macOS with Google Chrome.
These issues may share an underlying metadata synchronization problem.
However, I am opening a separate issue because this report specifically concerns previously loaded metadata being overwritten with an empty object, even without an intentional title change.
The debugging evidence above demonstrates that this affects not only the note title but also other metadata properties in the client-side application state.
I have not yet confirmed whether all three issues share the same root cause.
Thank you for looking into this.
- Linguagem predominante
- Sem dados de linguagem
- Estrelas
- 40
- Forks
- 9
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de hackmdio/hackmd-io-issues
-
bug
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 62/100
hackmdio/hackmd-io-issues#121 ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 15/100
hackmdio/hackmd-io-issues#447 ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
hackmdio/hackmd-io-issues#446 ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 22/100
hackmdio/hackmd-io-issues#445 · 3 comentários ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 30/100
hackmdio/hackmd-io-issues#444 · 1 comentário ·
Todas as issues de hackmdio/hackmd-io-issues
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 60/100
quelea-projection/Quelea#749 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
Jason-Vaughan/TangleClaw#3360 · 2 comentários ·
Mantenedores costumam responder em até 1 dia