Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash dump files littering home directory #11871

Open
Terrance opened this issue Feb 20, 2025 · 2 comments
Open

Crash dump files littering home directory #11871

Terrance opened this issue Feb 20, 2025 · 2 comments
Labels
bug It's a bug

Comments

@Terrance
Copy link

Operating system

Windows

Joplin version

3.1.24

Desktop version info

Joplin 3.1.24 (prod, win32)

Client ID: 2ca5a676b7954ae89721faa06464e5e6
Sync Version: 3
Profile Version: 47
Keychain Supported: Yes

Revision: d581264

Backup: 1.4.2
Get Notebook ID: 1.0.1
Joplin Note Attachement rename: 1.2.2
Outline: 1.5.13

Current behaviour

#9941 tracks a repeated crash which produces a joplin_crash_dump_*.json file on most shutdowns. As that's logged already and pending a fix, there's no immediate action to take with these crash files. They are however piling up in my home directory, which isn't an appropriate place to be dumping log files (particularly when they're not even in a subfolder).

Expected behaviour

Crash dump files to be placed in a suitable place, out of the way but still accessible when needed (for example, %APPDATA%\Joplin on Windows).

Nice to have: make this a user-configurable location, or allow turning off their generation in the first place.

Logs

No response

@Terrance Terrance added the bug It's a bug label Feb 20, 2025
@personalizedrefrigerator
Copy link
Collaborator

I'm also experiencing this on Fedora 41.

For reference, I think that this is the line that's causing the problem:

writeFileSync(`${homedir()}/joplin_crash_dump_${date}.json`, JSON.stringify(errorEventWithLog, null, '\t'), 'utf-8');

@Terrance
Copy link
Author

Without much in the way of non-browser JS experience, and with just some initial searches of the code for other precedents, I would suggest something like:

import { mkdirSync } from 'fs';
import { env } from 'process';
import * as utils from '.../utils.js';
let target = 'crash-dumps';
if (utils.isWindows()) {
    target = (env.LOCALAPPDATA || `${homedir()}\\AppData\\Local`) + `\\Joplin\\${target}`;
} else if (utils.isMac()) {
    target = `${homedir()}/Library/Preferences/Joplin/${target}`;
} else { // UNIX or unknown
    target = (env.XDG_CACHE_HOME || `${homedir()}/.cache`) + `/joplin/${target}`;
}
mkdirSync(target, {recursive: true});
writeFileSync(`${target}/joplin_crash_dump_${date}.json`, JSON.stringify(errorEventWithLog, null, '\t'), 'utf-8');

Which should result in:

  • Windows: C:\Users\<username>\AppData\Local\Joplin\crash-dumps
  • Mac: /Users/<username>/Library/Preferences/Joplin/crash-dumps
    (This is a guess as I've never used Mac myself; there may be a more appropriate path for this.)
  • Linux etc.: /home/<username>/.cache/joplin/crash-dumps

I'm not sure if Android comes through here, and if so then how the path is formed either currently or for an equivalent to the above (I'd suggest <external storage>/Android/data/<app ID>/crash-dumps).

Of course if we have helpers somewhere for working with an app data location then it should probably use those! That said, I have deliberately used local app data (as opposed to roaming) on Windows, and the standard cache location (as opposed to user data) for Linux, which existing helpers are probably not using for the rest of user data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug
Projects
None yet
Development

No branches or pull requests

2 participants