question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m getting UnhandledPromiseRejectionWarning: Error: read ECONNRESET,

Is there a debug mode so I can understand what’s happening here?

my config file:

module.exports = {
  commands: [
    [
      "components",
      {
        fileId: "XXXX",
        onlyFromPages: ["icons", "illustrations"],
        transformers: [
          require("@figma-export/transform-svg-with-svgo")({
            plugins: [{ removeViewBox: false }, { removeDimensions: true }],
          }),
        ],
        outputters: [
          async (pages) => {
            const output = "./public";
            fs.mkdirSync(output, { recursive: true });
            console.log("OUTPUT", output);
            try {
              pages.forEach(({ name: pageName, components }) => {
                console.log("PAGE", pageName);
                components.forEach(({ name: componentName, svg }) => {
                  const filePath = path.resolve(output, `${componentName}.svg`);

                  let p = filePath.split("/");
                  p.pop();
                  p = p.join("/");

                  fs.mkdirSync(p, { recursive: true });

                  fs.writeFileSync(filePath, svg);

                  console.log("GENERATED", filePath, componentName);
                });
              });
            } catch (e) {
              console.log(e);
            }
          },
        ],
      },
    ],
  ],
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marcomontalbanocommented, Nov 7, 2020

Hi @berkaey, thank you for all these details.

I tried by using the same configuration you provided (off-course with a different Figma File) and everything worked properly. For sure I’ve to handle all promise rejection and improve the application log to better understand the root cause.

The error ECONNRESET should be not related to transformers since they just manipulate strings. ECONNRESET is related to a network issue. Figma Export uses the network to connect to Figma Api and to download SVGs. I can also improve the application there to better handle exceptions from Figma.

Rate Limit is for sure another option, I’ll investigate more.

Thanks, I’ll keep you posted.

0reactions
berkaeycommented, Nov 16, 2020

Hi @berkaey, I’m going to close the issue since I just release the new version v3.2.0.

I was looking at your configuration file and seems to me that you could replace your custom outputter with @figma-export/output-components-as-svg.

outputters: [
    require('@figma-export/output-components-as-svg')({
        output: './public',
        getDirname: (options) => options.dirname,
    })
]

The option getDirname gives you the ability to change the folder structure when exporting components.

yes I noticed that too, but I also replace some IDs in SVG file so this is why I implemented it like this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I debug error ECONNRESET in Node.js?
ECONNRESET occurs when the server side closes the TCP connection and your request to the server is not fulfilled. The server ...
Read more >
What does “Error: read ECONNRESET” mean?
You might have guessed it already: it's a connection error. "ECONNRESET" means the other side of the TCP conversation abruptly closed its end...
Read more >
Fixing an ECONNRESET error
The ECONRESET error means that the server unexpectedly closed the connection and the request to the server was not fulfilled. Connection-related ...
Read more >
Return code ECONNRESET for TCP/IP
Depending upon the platform or platforms your enterprise uses, you receive the following return code when the connection is reset by peer (ECONNRESET):....
Read more >
read ECONNRESET when trying a simple GET request ...
Error: read ECONNRESET is a problem in Node.js. There seesm to be something wrong yout TCP connection setup. Can you share a code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found