0

I'm tring to deploy 0x-api locally, when I use the api /sra/v4/order to create an order, I got the 500 Internal Server Error, the error log is :

[1644904993870] INFO  (26691 on DESKTOP-VKM9D90): request errored
    req: {
      "id": "cd210fa8-0ac4-4848-bb6b-b380f843fbbf",
      "method": "POST",
      "url": "/sra/v4/order",
      "query": {},
      "params": {},
      "headers": {
        "host": "172.28.210.112:6540",
        "connection": "keep-alive",
        "content-length": "801",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36",
        "content-type": "application/json",
        "accept": "*/*",
        "origin": "http://localhost:3000",
        "referer": "http://localhost:3000/",
        "accept-encoding": "gzip, deflate",
        "accept-language": "zh-CN,zh;q=0.9,ja;q=0.8,en;q=0.7"
      },
      "remoteAddress": "::ffff:172.28.208.1",
      "remotePort": 49295,
      "body": {
        "makerToken": "0x55D8C9bAe15019bFB02b52CB3ceEd05b783ea275",
        "takerToken": "0x3205e1c8832959c21207439bd33fc55279de98cc",
        "makerAmount": "100000000",
        "takerAmount": "100000000",
        "maker": "0x5409ed021d9299bf6814279a6a1411a7e866a631",
        "taker": "0x0000000000000000000000000000000000000000",
        "chainId": 1337,
        "verifyingContract": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
        "takerTokenFeeAmount": "0",
        "sender": "0x0000000000000000000000000000000000000000",
        "feeRecipient": "0x0000000000000000000000000000000000000000",
        "pool": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "salt": "1644904988573",
        "expiry": "1644906189",
        "signature": {
          "r": "0x2cb96f8727562caa20913e99218a798858a26cbd11b528cf1de03403456fe1d5",
          "s": "0x1c9a2185df7740b040f8d6b27f490917b1ed5713ae18622b667558c7c8831603",
          "v": 27,
          "signatureType": 2
        }
      }
    }
    res: {
      "statusCode": 500,
      "headers": {
        "x-powered-by": "Express",
        "access-control-allow-origin": "*",
        "content-type": "application/json; charset=utf-8",
        "content-length": "65",
        "etag": "W/\"41-4KPMPxCSTV9SE3PKzeD1vY+B2P8\""
      },
      "statusMessage": "Internal Server Error"
    }
    err: {
      "type": "Error",
      "message": "failed with status code 500",
      "stack":
          Error: failed with status code 500
              at ServerResponse.onResFinished (/home/cyrto/software/0x-api/node_modules/pino-http/logger.js:77:38)
              at ServerResponse.emit (node:events:532:35)
              at ServerResponse.emit (node:domain:475:12)
              at onFinish (node:_http_outgoing:830:10)
              at callback (node:internal/streams/writable:552:21)
              at afterWrite (node:internal/streams/writable:497:5)
              at afterWriteTick (node:internal/streams/writable:484:10)
              at processTicksAndRejections (node:internal/process/task_queues:82:21)
    }
    responseTime: 2013

I found the error was caused by send a timeout post http request, the source code is the following:

https://github.com/0xProject/0x-api/blob/master/src/utils/order_watcher.ts#L16

export class OrderWatcher implements OrderWatcherInterface {
    // tslint:disable:prefer-function-over-method
    public async postOrdersAsync(orders: SignedLimitOrder[]): Promise<void> {
        try {
            await axios.post(`${ORDER_WATCHER_URL}/orders`, orders, {
                headers: {
                    'Content-Type': 'application/json',
                },
                timeout: 1000,
            });
        } catch (err) {
            if (err.response.data) {
                throw new ValidationError(err.response.data.validationErrors);
            } else if (err.request) {
                throw new InternalServerError('failed to submit order to order-watcher');
            } else {
                throw new InternalServerError('failed to prepare the order-watcher request');
            }
        }
    }
}

the source code has a Environment Variable named "ORDER_WATCHER_URL", so what should I do to config the variable?

1 Answer 1

0

The recommended solution is that you would need to run the block-watcher+ order-watcher yourselves. I’ve messaged you on Discord to discuss what’s needed to set this up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.