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

Handle ECONNRESET on image file request. #78

Open
NikitaIT opened this issue Oct 26, 2021 · 2 comments
Open

Handle ECONNRESET on image file request. #78

NikitaIT opened this issue Oct 26, 2021 · 2 comments

Comments

@NikitaIT
Copy link

NikitaIT commented Oct 26, 2021

I/O

In:

npx tplant --input ./**/*.ts --output ./Playground.svg

Out:

npx: installed 15 in 3.177s
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: socket hang up
    at connResetException (internal/errors.js:607:14)
    at Socket.socketOnEnd (_http_client.js:493:23)
    at Socket.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ClientRequest instance at:
    at Socket.socketOnEnd (_http_client.js:493:9)
    at Socket.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  code: 'ECONNRESET'
  

It is clear that this is not a mistake on your part. However, it would be nice to write something meaningful in addition to the log.

Proposed solution:

  1. Check URL maxlength and assert (414 Request-URI Too Large).
    path: `/plantuml/${extension}/${encode(input)}`
  2. Handle ECONNRESET or add description about diagram size.
@bafolts bafolts changed the title Handle ECONNRESET Handle ECONNRESET on image file request. Oct 26, 2021
@bafolts
Copy link
Owner

bafolts commented Oct 26, 2021

When I run this command the Playground.svg file is generated without error. Adding additional error handling makes sense but not sure it will address the error seen here. Do you see the http request fail for requestImageFile?

@NikitaIT
Copy link
Author

@bafolts I tried on a project with a puml of 8000 lines. Now I wrote a small example that can be run in the console.

script.js

#!/usr/bin/env node

const http = require('http');

const okLen = 10; // ok if <= 92
const errorLen = 93; // ECONNRESET if >= 93
const extension = 'svg';

http.get({
    host: 'www.plantuml.com',
    path: `/plantuml/${extension}/${encodeURI(input().repeat(errorLen))}`,
});

function input() {
    return `
    class LinkedListItem<T> {
        +item: T
        +next: LinkedListItem<T>
    }
    `;
}

Run:

node ./script.js

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

No branches or pull requests

2 participants