[Bug] Emoji triggers PDF-export crash and restarts container (CodiMD 2.6.0)

Đang mở
#1,932 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

  • #1953 của @lakshay122007 — đã đóng, không merge

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
docker-compose, javascript, nodejs
Lĩnh vực
backend, devops

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện việc xuất PDF với một emoji và kiểm tra lời gọi PhantomJS của node_modules/markdown-pdf/phantom/render.js được hiển thị trong log. So sánh các tùy chọn PDF engine hiện có và các phiên bản dependency, sau đó xác minh rằng một ghi chú chứa emoji tạo PDF thành công mà không làm PhantomJS bị crash hoặc container bị khởi động lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

Exporting a note to PDF in CodiMD 2.6.0 crashes PhantomJS whenever the note contains certain emoji characters, which restarts the whole container.

To Reproduce

  1. Create or edit a note.
  2. Insert any emoji (e.g. 😀).
  3. Click Export → PDF.
  4. The request hangs and the container restarts.

Expected behavior

  • A PDF should be generated successfully.
  • The service should remain online.

Actual behavior

  • PDF generation fails.
  • docker logs show PhantomJS crashing with SIGFPE.
  • The CodiMD container restarts automatically.

Environment

Item Value
CodiMD ver. 2.6.0
Deployment docker-compose
Node ver. 16.20.2 (image default)
Base OS Debian Buster
PDF engine markdown-pdf + PhantomJS

docker-compose excerpt (masked)

click to expand
services:
  codimd:
    image: <PRIVATE_REGISTRY>/hackmdio/hackmd:2.6.0
    environment:
      CMD_URL_PATH: codimd
      CMD_DOMAIN: <YOUR_DOMAIN>
      CMD_PROTOCOL_USESSL: "true"
      QT_QPA_PLATFORM: ""
      # Database
      CMD_DB_URL: postgres://codimd:<MASKED_PW>@codimd_db/codimd
      # Misc
      CMD_EMAIL: "false"
      CMD_PLANTUML_SERVER: https://<YOUR_DOMAIN>/plantuml
      CMD_ALLOW_ANONYMOUS: "false"
      CMD_ALLOW_ANONYMOUS_EDITS: "false"
      CMD_CSP_ENABLE: "false"

Logs (full excerpt)

2025-07-09T06:13:04.445Z info:  <MASKED_IP> - - [09/Jul/2025:06:13:04 +0000] "GET /me HTTP/1.1" 304 - "https://<YOUR_DOMAIN>/codimd/ixLMZtInSNiOnrbOkQ-Q_w" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0"
2025-07-09T06:13:06.517Z info:  <MASKED_IP> - - [09/Jul/2025:06:13:06 +0000] "GET /uploads/upload_845dbee74d2337302b91fb126a4691db.png HTTP/1.1" 200 32405 "https://<YOUR_DOMAIN>/codimd/ixLMZtInSNiOnrbOkQ-Q_w" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0"
2025-07-09T06:13:20.968Z info:  deserializeUser: c35f23dd-2732-46b7-9283-15b14eac234b
2025-07-09T06:13:21.478Z error: uncaughtException: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-<MASKED>.html /tmp/tmp-<MASKED>.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Error: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-<MASKED>.html /tmp/tmp-<MASKED>.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
    at ChildProcess.exithandler (node:child_process:402:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Socket.<anonymous> (node:internal/child_process:458:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:301:12)
2025-07-09T06:13:21.481Z error:  Process will exit now.
Info: try to connect to tcp://codimd_db in port 5432
2025/07/09 06:13:22 portchecker.go:56: dial tcp codimd_db:5432: connect: connection success

Possible cause / context

Potential solutions

  1. Upgrade to CodiMD 3.x (if it has moved to a Chromium/Puppeteer backend).
  2. Replace PhantomJS with Puppeteer/Playwright in a custom build.
  3. Test latest phantomjs-prebuilt patch to confirm whether the crash persists.

Help wanted

  • Can maintainers reproduce this crash with an emoji-containing note?
  • Is there an official plan to migrate away from PhantomJS?
  • Any patch or workaround would be greatly appreciated.
Ngôn ngữ chính
JavaScript
Star
10.2k
Fork
1.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của hackmdio/codimd

Tất cả issue của hackmdio/codimd

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.