Skip to content

dprint hangs when two process plugins run (.mts vs. .java) #969

Closed

Description

@marioplumbeer

Note: I don't know yet if this is a bug with dprint or with my plugins, but I have ran out of ideas on how to troubleshoot this.


Version: 0.49.0

Hey folks, I'm not super sure about the root cause, but when I run two custom process plugins, one written in MTS and another in Java, dprint hangs and doesn't exit. I ran it with verbose logs and I can't see anything unusual.

I ran strace for the dprint parent process and this is what it returns:

$ sudo strace -p 154417

strace: Process 154417 attached
futex(0x608bb0eb8e00, FUTEX_WAIT_BITSET_PRIVATE, 0, NULL, FUTEX_BITSET_MATCH_ANY

These were the last log lines from one of the plugins:

[custom-dprint-plugin-prettier]
Received 12 bytes <Buffer 00 00 00 06 00 00 00 03 ff ff ff ff>
Read 4 bytes <Buffer 00 00 00 06>
Reading 4 bytes
Read 4 bytes <Buffer 00 00 00 03>
Reading 4 bytes
Read 4 bytes <Buffer ff ff ff ff>
Read message ShutdownMessage { messageId: 6, kind: 3 }
Shutting down
Worker 1 exited with code 1
Worker 2 exited with code 1
Worker 3 exited with code 1
Worker 4 exited with code 1
Writing message SuccessResponseMessage { messageId: 7, kind: 0, originalMessageId: 6 }
Wrote <Buffer 00 00 00 07>
Wrote <Buffer 00 00 00 00>
Wrote <Buffer 00 00 00 06>
Wrote <Buffer ff ff ff ff>

I can also see 4 instances of the other plugin (java) running:

coder     164142  0.0  0.0   6872  3200 pts/5    S+   08:33   0:00 my-custom-java-plugin -- --parent-pid 164126 --init
coder     164620  0.0  0.0   6868  3328 pts/5    S+   08:33   0:00 my-custom-java-plugin-- --parent-pid 164126
coder     164591  0.1  0.0 19722636 45540 pts/5  Sl+  08:33   0:00 my.custom.java.plugin.Main --parent-pid 164126 --init
coder     165058  0.1  0.0 19722636 45448 pts/5  Sl+  08:33   0:00 my.custom.java.plugin.Main --parent-pid 164126

Both plugins are private, but they were written in .mts and .java based on https://github.com/dprint/dprint-plugin-roslyn (C#).

Activity

  1. marioplumbeer commented on Mar 6, 2025

    @marioplumbeer
    Author

    Update: I passed the same .java process plugin twice to dprint, and it didn't hang.

  2. bradzacher commented on Mar 6, 2025

    @bradzacher

    --verbose logs:

    [DEBUG] Reading file: /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.json
    [DEBUG] Creating directory: /Users/bjz/Library/Caches/dprint/cache/locks
    [DEBUG] Checking path exists: /Users/bjz/work/canva/dprint.json
    [DEBUG] Reading file: /Users/bjz/work/canva/dprint.json
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/config/base.jsonc
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/config/plugins/toml/config.jsonc
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/config/plugins/exec/config.jsonc
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/config/plugins/prettier/config.jsonc
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/config/plugins/palantir-java-format/config.jsonc
    [DEBUG] Reading file: /Users/bjz/Library/Caches/dprint/cache/plugins/dprint-plugin-toml/0.6.2-5.0.2-aarch64-8364491308569144374
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/dotslash/exec-plugin/plugin.json
    [DEBUG] Checking path exists: /Users/bjz/Library/Caches/dprint/cache/plugins/dprint-plugin-exec/0.4.4/aarch64/dprint-plugin-exec
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/prettier/dprint_prettier/plugin/plugin.json
    [DEBUG] Checking path exists: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-prettier/0.0.6/aarch64/canva-dprint-plugin-prettier
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/palantir-java-format/plugin/plugin.json
    [DEBUG] Checking path exists: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/null/aarch64/canva-dprint-plugin-palantir-java-format
    [DEBUG] Could not find process plugin at /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/null/aarch64/canva-dprint-plugin-palantir-java-format. Forgetting from cache and retrying.
    [DEBUG] Acquiring file lock at /Users/bjz/Library/Caches/dprint/cache/locks/.13736044358209205503.lock
    [DEBUG] Acquired file lock at /Users/bjz/Library/Caches/dprint/cache/locks/.13736044358209205503.lock
    [DEBUG] Writing file: /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.5cb779b8.tmp
    [DEBUG] Renaming /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.5cb779b8.tmp -> /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.json
    [DEBUG] Deleting directory: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/null/aarch64
    [DEBUG] Reading file: /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.json
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/palantir-java-format/plugin/plugin.json
    [DEBUG] Reading file: /Users/bjz/work/canva/tools/dprint/palantir-java-format/plugin/plugin.zip
    [DEBUG] Deleting directory: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64
    [DEBUG] Creating directory: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64
    [DEBUG] Extracting zip file to directory: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64
    [DEBUG] Creating directory: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64
    [DEBUG] Writing file: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64/canva-dprint-plugin-palantir-java-format
    [DEBUG] Creating directory: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64/tools/dprint/palantir-java-format/plugin
    [DEBUG] Writing file: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64/tools/dprint/palantir-java-format/plugin/canva-dprint-plugin-palantir-java-format
    [DEBUG] Checking path exists: /Users/bjz/Library/Caches/dprint/cache/plugins/canva-dprint-plugin-palantir-java-format/0.0.1/aarch64/canva-dprint-plugin-palantir-java-format
    [DEBUG] Writing file: /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.a43e4b43.tmp
    [DEBUG] Renaming /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.a43e4b43.tmp -> /Users/bjz/Library/Caches/dprint/cache/plugin-cache-manifest.json
    [DEBUG] Creating instance of dprint-plugin-toml
    [DEBUG] Creating instance of dprint-plugin-exec
    [DEBUG] Creating instance of canva-dprint-plugin-prettier
    [DEBUG] Creating instance of canva-dprint-plugin-palantir-java-format
    [DEBUG] Created instance of dprint-plugin-toml in 1ms
    [DEBUG] Created instance of dprint-plugin-exec in 67ms
    [DEBUG] Created instance of canva-dprint-plugin-prettier in 330ms
    [DEBUG] Created instance of canva-dprint-plugin-palantir-java-format in 897ms
    # ... log line for Globbing: GlobPatterns ...
    [DEBUG] Checking path exists: /Users/bjz/work/canva/.git
    # ... logs announcing traversing all .gitignore files ...
    [DEBUG] Finished globbing in 4640ms
    [DEBUG] Creating directory: /Users/bjz/Library/Caches/dprint/cache/incremental
    [DEBUG] Reading file: /Users/bjz/Library/Caches/dprint/cache/incremental/3964385621458748716
    [DEBUG] Running for config: /Users/bjz/work/canva/dprint.json
    [DEBUG] Max threads: 14
    Thread count: 10
    [DEBUG] Reading file: /Users/bjz/work/canva/web/src/base/preconditions.ts
    [DEBUG] No change: /Users/bjz/work/canva/web/src/base/preconditions.ts
    [DEBUG] Writing file: /Users/bjz/Library/Caches/dprint/cache/incremental/3964385621458748716.46389b29.tmp
    [DEBUG] Renaming /Users/bjz/Library/Caches/dprint/cache/incremental/3964385621458748716.46389b29.tmp -> /Users/bjz/Library/Caches/dprint/cache/incremental/3964385621458748716
    [DEBUG] Dropped dprint-plugin-toml (1 instances) in 0ms
    
  3. bradzacher commented on Mar 6, 2025

    @bradzacher

    Okay so after some debugging we've figured out that the bug was in our palantir-java-format plugin. It spawned a repeated timer to check the parent process ID and that timer wasn't properly cancelled -- this meant the process was held running forever. The fix was easy enough -- cancel that timer when the "shutdown" message is received.

    The open question, however, is why the plugin worked fine when run without our prettier plugin..

  4. dsherret commented on Mar 7, 2025

    @dsherret
    Member

    The open question, however, is why the plugin worked fine when run without our prettier plugin..

    Does it happen when running with --incremental=false?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions