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

TypeError: cannot read property 'HTTP' of undefined #610

Open
nabetti1720 opened this issue Sep 26, 2024 · 1 comment
Open

TypeError: cannot read property 'HTTP' of undefined #610

nabetti1720 opened this issue Sep 26, 2024 · 1 comment

Comments

@nabetti1720
Copy link
Contributor

nabetti1720 commented Sep 26, 2024

The error message here is not very important. As we have raised in other issues, there still seems to be a way of writing modules that require does not work on LLRT.

const a = require('@aws-sdk/client-rds-data')
% llrt ./src/index.js
TypeError: cannot read property 'HTTP' of undefined
  at <anonymous> (/Users/shinya/Workspaces/hono-test/node_modules/@smithy/util-endpoints/dist-cjs/index.js:200:36)
      at <anonymous> (/Users/shinya/Workspaces/hono-test/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js:62:29)
      at <anonymous> (/Users/shinya/Workspaces/hono-test/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js:41:29)
      at <anonymous> (/Users/shinya/Workspaces/hono-test/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:63:36)
      at <anonymous> (/Users/shinya/Workspaces/hono-test/src/index.js:6:11)
      at <anonymous> (eval_script:1:5)

By the way, if you load @smithy/util-endpoints, you can see the difference in behavior from Node.js as follows.

@smithy/util-endpoint (with llrt-dawrin-arm64-no-sdk):

const a = require('@smithy/util-endpoints')
console.log(a)
% llrt ./src/reproduction.js
{}

% node ./src/reproduction.js
{
  EndpointCache: [Getter],
  EndpointError: [Getter],
  customEndpointFunctions: [Getter],
  isIpAddress: [Getter],
  isValidHostLabel: [Getter],
  resolveEndpoint: [Getter]
}

What is even stranger is that when I run the reproduced program with the part that was in error extracted, it works.

var import_types3 = require("@smithy/types");
var DEFAULT_PORTS = {
  [import_types3.EndpointURLScheme.HTTP]: 80,              // -> @smithy/util-endpoints/dist-cjs/index.js:200:36
  [import_types3.EndpointURLScheme.HTTPS]: 443
};
console.log(DEFAULT_PORTS);  // debug
% llrt ./src/reproduction.js
{
  http: 80,
  https: 443
}

% node ./src/reproduction.js
{ http: 80, https: 443 }
@nabetti1720
Copy link
Contributor Author

nabetti1720 commented Sep 26, 2024

Even stranger behavior included the following.

  1. When modules that have no dependencies on each other are loaded.
const a = require("tinybench")
//const a = require('@smithy/types')
const b = require('@smithy/util-endpoints')
console.log(b)
% llrt ./src/reproduction.js
{}

% node ./src/reproduction.js
{
  EndpointCache: [Getter],
  EndpointError: [Getter],
  customEndpointFunctions: [Getter],
  isIpAddress: [Getter],
  isValidHostLabel: [Getter],
  resolveEndpoint: [Getter]
}
  1. If a module with prior dependencies is loaded (but the variable to be assigned is irrelevant)
//const a = require("tinybench")
const a = require('@smithy/types')
const b = require('@smithy/util-endpoints')
console.log(b)
% llrt ./src/reproduction.js
TypeError: cannot read property 'HTTP' of undefined
  at <anonymous> (/Users/shinya/Workspaces/hono-test/node_modules/@smithy/util-endpoints/dist-cjs/index.js:200:36)
      at <anonymous> (/Users/shinya/Workspaces/hono-test/src/reproduction.js:3:11)
      at <anonymous> (eval_script:1:5)

% node ./src/reproduction.js
{
  EndpointCache: [Getter],
  EndpointError: [Getter],
  customEndpointFunctions: [Getter],
  isIpAddress: [Getter],
  isValidHostLabel: [Getter],
  resolveEndpoint: [Getter]
}

Apparently there are two issues.

  • It is not possible to load a module like @smithy/types.
  • If the same module has been pre-required, it has some effect on the second and subsequent requirments.

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

1 participant