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

Getting UnknownEndpoint error #272

Open
SatoshiMD opened this issue Jun 21, 2022 · 1 comment
Open

Getting UnknownEndpoint error #272

SatoshiMD opened this issue Jun 21, 2022 · 1 comment

Comments

@SatoshiMD
Copy link

SatoshiMD commented Jun 21, 2022

I'm getting this error below when trying to mock s3

UnknownEndpoint: Inaccessible host: `mock-bucket.s3.mk-mock-1.amazonaws.com' at port `undefined'. This service may not be available in the `mk-mock-1' region.
          at Request.ENOTFOUND_ERROR (C:\Users\smidorikawa\_repos\eng\ratesbot\src\handlers\node_modules\aws-sdk\lib\event_listeners.js:546:46)
          at Request.callListeners (C:\Users\smidorikawa\_repos\eng\ratesbot\src\handlers\node_modules\aws-sdk\lib\sequential_executor.js:111:20)
          at Request.emit (C:\Users\smidorikawa\_repos\eng\ratesbot\src\handlers\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
          at Request.emit (C:\Users\smidorikawa\_repos\eng\ratesbot\src\handlers\node_modules\aws-sdk\lib\request.js:702:14)
          at error (C:\Users\smidorikawa\_repos\eng\ratesbot\src\handlers\node_modules\aws-sdk\lib\event_listeners.js:385:22)
          at ClientRequest.<anonymous> (C:\Users\smidorikawa\_repos\eng\ratesbot\src\handlers\node_modules\aws-sdk\lib\http\node.js:105:9)
          at ClientRequest.emit (events.js:375:28)
          at ClientRequest.emit (domain.js:470:12)
          at TLSSocket.socketErrorListener (_http_client.js:475:9)
          at TLSSocket.emit (events.js:375:28)
          at TLSSocket.emit (domain.js:470:12)
          at emitErrorNT (internal/streams/destroy.js:106:8)
          at emitErrorCloseNT (internal/streams/destroy.js:74:3)
          at processTicksAndRejections (internal/process/task_queues.js:82:21) {
        code: 'UnknownEndpoint',
        region: 'mk-mock-1',
        hostname: 'mock-bucket.s3.mk-mock-1.amazonaws.com',
        retryable: true,
        originalError: Error: getaddrinfo ENOTFOUND mock-bucket.s3.mk-mock-1.amazonaws.com
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:26) {
          errno: -3008,
          code: 'NetworkingError',
          syscall: 'getaddrinfo',
          hostname: 'mock-bucket.s3.mk-mock-1.amazonaws.com',
          region: 'mk-mock-1',
          retryable: true,
          time: 2022-06-21T14:33:07.524Z
        },
        time: 2022-06-21T14:33:07.524Z

Here is my test script

const AWS = require('aws-sdk')
const AWS_MOCK = require('aws-sdk-mock')

describe('Test S3', () => {
  beforeEach(() => {
    process.env.BUCKET = 'mock-bucket'
  })

  it('Test s3 get object', async () => {
    const event = {
      objectKey: 'demo.json'
    }

    AWS_MOCK.mock('S3', 'getObject', function (params, callback) {
      callback('not found', null)

      const body = {
        Body: JSON.stringify({})
      }
      callback(null, body)
    })
  })
})

Also I'm using v5.1.0 aws-sdk-mock

Any idea?

@SatoshiMD SatoshiMD changed the title Getting UnknownEndpoint Getting UnknownEndpoint error Jun 21, 2022
@vijaypatidar
Copy link

Try to import mock module before importing the original one. Like this

import AWSMock from 'aws-sdk-mock';
import AWS from 'aws-sdk';

// your code ...

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