Skip to content

Commit

Permalink
debug: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
07akioni committed Apr 18, 2024
1 parent 27092fd commit a1caff9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion packages/node/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const adapter: LylaAdapter<LylaAdapterMeta> = ({
} => {
// Since baseurl exits, it won't throw an error.
// We don't parse it in @lylajs/core since url can be a relative path after resolution.
const parsedUrl = new URL(url, 'http://localhost')
const parsedUrl = new URL(url, 'http://127.0.0.1')

let requestBodyStream: Readable | null = null

Expand Down
24 changes: 12 additions & 12 deletions packages/test/demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const handlers: Handler[] = [
console.log(body)
})
axios
.get('http://localhost:8092', {
baseURL: 'http://localhost:3000',
.get('http://127.0.0.1:8092', {
baseURL: 'http://127.0.0.1:3000',
responseType: 'json'
})
.then((resp) => {
Expand Down Expand Up @@ -246,7 +246,7 @@ const handlers: Handler[] = [
[
'cors set cookie',
async () => {
const resp = await lyla.get('http://localhost:8092/api/get-set-cookie', {
const resp = await lyla.get('http://127.0.0.1:8092/api/get-set-cookie', {
withCredentials: true
})
console.log(resp)
Expand All @@ -256,7 +256,7 @@ const handlers: Handler[] = [
'cors get with credentials',
async () => {
const resp = await lyla.get(
'http://localhost:8092/api/get-return-headers',
'http://127.0.0.1:8092/api/get-return-headers',
{ withCredentials: true }
)
console.log(resp)
Expand All @@ -266,7 +266,7 @@ const handlers: Handler[] = [
'cors get without credentials',
async () => {
const resp = await lyla.get(
'http://localhost:8092/api/get-return-headers'
'http://127.0.0.1:8092/api/get-return-headers'
)
console.log(resp)
}
Expand All @@ -275,7 +275,7 @@ const handlers: Handler[] = [
'cors post cookie',
async () => {
const resp = await lyla.post(
'http://localhost:8092/api/post-set-cookie',
'http://127.0.0.1:8092/api/post-set-cookie',
{ withCredentials: true }
)
console.log(resp)
Expand All @@ -285,7 +285,7 @@ const handlers: Handler[] = [
'cors post with credentials',
async () => {
const resp = await lyla.post(
'http://localhost:8092/api/post-return-headers',
'http://127.0.0.1:8092/api/post-return-headers',
{ withCredentials: true }
)
console.log(resp)
Expand All @@ -295,7 +295,7 @@ const handlers: Handler[] = [
'cors post without credentials',
async () => {
const resp = await lyla.post(
'http://localhost:8092/api/post-return-headers'
'http://127.0.0.1:8092/api/post-return-headers'
)
console.log(resp)
}
Expand All @@ -319,7 +319,7 @@ const handlers: Handler[] = [
'test',
async () => {
try {
await lyla.get('http://localhost:8092/api/get-check-cookie')
await lyla.get('http://127.0.0.1:8092/api/get-check-cookie')
} catch (e) {
debugger
}
Expand All @@ -339,7 +339,7 @@ const handlers: Handler[] = [
'extend test',
async () => {
const { lyla: extended } = createLyla({
baseUrl: 'http://localhost:8092',
baseUrl: 'http://127.0.0.1:8092',
context: null
})
let resp: any
Expand Down Expand Up @@ -466,10 +466,10 @@ const handlers: Handler[] = [
'same headers',
async () => {
const { headers } = await lyla.get(
'http://localhost:8091/api/get-set-same-header'
'http://127.0.0.1:8091/api/get-set-same-header'
)
console.log(headers)
const resp = await fetch('http://localhost:8091/api/get-set-same-header')
const resp = await fetch('http://127.0.0.1:8091/api/get-set-same-header')
console.log([...resp.headers.entries()])
}
],
Expand Down
24 changes: 12 additions & 12 deletions packages/test/node-tests/node-universal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { describe, expect, it } from 'vitest'

describe('node basic', () => {
it('/api/get-text', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-text')
const resp = await lyla.get('http://127.0.0.1:8091/api/get-text')

Check failure on line 7 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/get-text

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.get ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:7:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, method: 'GET', url: 'http://127.0.0.1:8091/api/get-text', responseType: 'text', headers: { accept: '*/*' } }, spread: 'Function<spread>' }
expect(resp.status).toBe(200)
expect(resp.body).toBe('hello world')
})

it('/api/get-json', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-json')
const resp = await lyla.get('http://127.0.0.1:8091/api/get-json')

Check failure on line 13 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/get-json

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.get ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:13:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, method: 'GET', url: 'http://127.0.0.1:8091/api/get-json', responseType: 'text', headers: { accept: '*/*' } }, spread: 'Function<spread>' }
expect(resp.status).toBe(200)
expect(resp.json).toStrictEqual({
key: 'value'
Expand All @@ -19,7 +19,7 @@ describe('node basic', () => {

it('/api/get-return-headers', async () => {
const resp = await lyla.get(

Check failure on line 21 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/get-return-headers

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.get ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:21:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, headers: { foo: 'bar', 'foo-baz': 'baz', accept: '*/*' }, method: 'GET', url: 'http://127.0.0.1:8091/api/get-return-headers', responseType: 'text' }, spread: 'Function<spread>' }
'http://localhost:8091/api/get-return-headers',
'http://127.0.0.1:8091/api/get-return-headers',
{
headers: {
foo: 'bar',
Expand All @@ -32,25 +32,25 @@ describe('node basic', () => {
})

it('/api/get-set-cookie', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-set-cookie', {})
const resp = await lyla.get('http://127.0.0.1:8091/api/get-set-cookie', {})

Check failure on line 35 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/get-set-cookie

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.get ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:35:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, method: 'GET', url: 'http://127.0.0.1:8091/api/get-set-cookie', responseType: 'text', headers: { accept: '*/*' } }, spread: 'Function<spread>' }
expect(resp.headers['set-cookie']).toBe('foo-get=bar')
expect(resp.headers['x-cors']).toBe('amazing')
})

it('/api/get-headers', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-headers')
const resp = await lyla.get('http://127.0.0.1:8091/api/get-headers')

Check failure on line 41 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/get-headers

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.get ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:41:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, method: 'GET', url: 'http://127.0.0.1:8091/api/get-headers', responseType: 'text', headers: { accept: '*/*' } }, spread: 'Function<spread>' }
expect(resp.headers['x-upper']).toBe('X-UPPER')
expect(resp.headers['x-lower']).toBe('x-lower')
})

it('/api/post-text', async () => {
const resp = await lyla.post('http://localhost:8091/api/post-text')
const resp = await lyla.post('http://127.0.0.1:8091/api/post-text')

Check failure on line 47 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/post-text

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.post ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:47:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, method: 'POST', url: 'http://127.0.0.1:8091/api/post-text', responseType: 'text', headers: { accept: '*/*' } }, spread: 'Function<spread>' }
expect(resp.status).toBe(200)
expect(resp.body).toBe('hello world')
})

it('/api/post-json', async () => {
const resp = await lyla.post('http://localhost:8091/api/post-json')
const resp = await lyla.post('http://127.0.0.1:8091/api/post-json')

Check failure on line 53 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/post-json

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.post ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:53:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, method: 'POST', url: 'http://127.0.0.1:8091/api/post-json', responseType: 'text', headers: { accept: '*/*' } }, spread: 'Function<spread>' }
expect(resp.status).toBe(200)
expect(resp.json).toStrictEqual({
key: 'value'
Expand All @@ -59,7 +59,7 @@ describe('node basic', () => {

it('/api/post-return-headers', async () => {
const resp = await lyla.post(

Check failure on line 61 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/post-return-headers

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.post ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:61:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, headers: { foo: 'bar', 'foo-baz': 'baz', accept: '*/*' }, method: 'POST', url: 'http://127.0.0.1:8091/api/post-return-headers', responseType: 'text' }, spread: 'Function<spread>' }
'http://localhost:8091/api/post-return-headers',
'http://127.0.0.1:8091/api/post-return-headers',
{
headers: {
foo: 'bar',
Expand All @@ -72,7 +72,7 @@ describe('node basic', () => {
})

it('/api/post-return-body', async () => {
const resp = await lyla.post('http://localhost:8091/api/post-return-body', {
const resp = await lyla.post('http://127.0.0.1:8091/api/post-return-body', {

Check failure on line 75 in packages/test/node-tests/node-universal.spec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

node-tests/node-universal.spec.ts > node basic > /api/post-return-body

LylaError[NETWORK]: Network error ❯ createLylaError ../core/lib/error.js:62:23 ❯ defineLylaError ../core/lib/error.js:67:23 ❯ onNetworkError ../core/lib/core.js:272:66 ❯ onNetworkError ../universal/lib/instance.js:74:24 ❯ ClientRequest.<anonymous> ../node/lib/adapter.js:112:9 ❯ ClientRequest.emit node:events:517:28 ❯ Socket.socketErrorListener node:_http_client:501:9 ❯ Socket.emit node:events:517:28 ❯ request ../core/lib/core.js:93:27 ❯ AsyncFunction.post ../core/lib/core.js:467:20 ❯ node-tests/node-universal.spec.ts:75:29 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { __lylaError: true, detail: { anyhow: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' }, web: undefined, node: { stack: 'Error: connect ECONNREFUSED 127.0.0.1:8091\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)', message: 'connect ECONNREFUSED 127.0.0.1:8091', errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8091, constructor: 'Function<Error>', name: 'Error', toString: 'Function<toString>' } }, error: undefined, response: undefined, context: undefined, requestOptions: { context: undefined, json: { foo: 'bar' }, method: 'POST', url: 'http://127.0.0.1:8091/api/post-return-body', responseType: 'text', body: '{"foo":"bar"}', headers: { 'content-type': 'application/json', accept: '*/*' } }, spread: 'Function<spread>' }
json: {
foo: 'bar'
}
Expand All @@ -84,7 +84,7 @@ describe('node basic', () => {
let resp: LylaResponse | null = null
let error: Error | null = null
try {
resp = await lyla.post('http://localhost:8091/api/error')
resp = await lyla.post('http://127.0.0.1:8091/api/error')
} catch (e) {
error = e
expect(isLylaError(e)).toBe(true)
Expand All @@ -103,7 +103,7 @@ describe('node progress', () => {
it('text `uploadProgress` & `downloadProgress`', async () => {
const up: number[] = []
const dp: number[] = []
await lyla.post('http://localhost:8091/api/post-return-body', {
await lyla.post('http://127.0.0.1:8091/api/post-return-body', {
responseType: 'text',
body: Array(2000000).fill('xxxx').join(''),
onUploadProgress(e) {
Expand All @@ -120,7 +120,7 @@ describe('node progress', () => {
it('buffer `uploadProgress` & `downloadProgress`', async () => {
const up: number[] = []
const dp: number[] = []
await lyla.post('http://localhost:8091/api/post-return-body', {
await lyla.post('http://127.0.0.1:8091/api/post-return-body', {
responseType: 'text',
body: Buffer.from(Array(2000000).fill('xxxx').join('')),
onUploadProgress(e) {
Expand Down
26 changes: 13 additions & 13 deletions packages/test/node-tests/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { describe, expect, it } from 'vitest'

describe('node basic', () => {
it('/api/get-text', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-text')
const resp = await lyla.get('http://127.0.0.1:8091/api/get-text')
expect(resp.status).toBe(200)
expect(resp.body).toBe('hello world')
})

it('/api/get-json', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-json')
const resp = await lyla.get('http://127.0.0.1:8091/api/get-json')
expect(resp.status).toBe(200)
expect(resp.json).toStrictEqual({
key: 'value'
Expand All @@ -25,7 +25,7 @@ describe('node basic', () => {

it('/api/get-return-headers', async () => {
const resp = await lyla.get(
'http://localhost:8091/api/get-return-headers',
'http://127.0.0.1:8091/api/get-return-headers',
{
headers: {
foo: 'bar',
Expand All @@ -38,25 +38,25 @@ describe('node basic', () => {
})

it('/api/get-set-cookie', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-set-cookie', {})
const resp = await lyla.get('http://127.0.0.1:8091/api/get-set-cookie', {})
expect(resp.headers['set-cookie']).toBe('foo-get=bar')
expect(resp.headers['x-cors']).toBe('amazing')
})

it('/api/get-headers', async () => {
const resp = await lyla.get('http://localhost:8091/api/get-headers')
const resp = await lyla.get('http://127.0.0.1:8091/api/get-headers')
expect(resp.headers['x-upper']).toBe('X-UPPER')
expect(resp.headers['x-lower']).toBe('x-lower')
})

it('/api/post-text', async () => {
const resp = await lyla.post('http://localhost:8091/api/post-text')
const resp = await lyla.post('http://127.0.0.1:8091/api/post-text')
expect(resp.status).toBe(200)
expect(resp.body).toBe('hello world')
})

it('/api/post-json', async () => {
const resp = await lyla.post('http://localhost:8091/api/post-json')
const resp = await lyla.post('http://127.0.0.1:8091/api/post-json')
expect(resp.status).toBe(200)
expect(resp.json).toStrictEqual({
key: 'value'
Expand All @@ -65,7 +65,7 @@ describe('node basic', () => {

it('/api/post-return-headers', async () => {
const resp = await lyla.post(
'http://localhost:8091/api/post-return-headers',
'http://127.0.0.1:8091/api/post-return-headers',
{
headers: {
foo: 'bar',
Expand All @@ -78,7 +78,7 @@ describe('node basic', () => {
})

it('/api/post-return-body', async () => {
const resp = await lyla.post('http://localhost:8091/api/post-return-body', {
const resp = await lyla.post('http://127.0.0.1:8091/api/post-return-body', {
json: {
foo: 'bar'
}
Expand All @@ -90,7 +90,7 @@ describe('node basic', () => {
let resp: LylaResponse | null = null
let error: Error | null = null
try {
resp = await lyla.post('http://localhost:8091/api/error')
resp = await lyla.post('http://127.0.0.1:8091/api/error')
} catch (e) {
error = e
expect(isLylaError(e)).toBe(true)
Expand All @@ -109,7 +109,7 @@ describe('node progress', () => {
it('text `uploadProgress` & `downloadProgress`', async () => {
const up: number[] = []
const dp: number[] = []
await lyla.post('http://localhost:8091/api/post-return-body', {
await lyla.post('http://127.0.0.1:8091/api/post-return-body', {
responseType: 'text',
body: Array(2000000).fill('xxxx').join(''),
onUploadProgress(e) {
Expand All @@ -126,7 +126,7 @@ describe('node progress', () => {
it('buffer `uploadProgress` & `downloadProgress`', async () => {
const up: number[] = []
const dp: number[] = []
await lyla.post('http://localhost:8091/api/post-return-body', {
await lyla.post('http://127.0.0.1:8091/api/post-return-body', {
responseType: 'text',
body: Buffer.from(Array(2000000).fill('xxxx').join('')),
onUploadProgress(e) {
Expand Down Expand Up @@ -158,7 +158,7 @@ describe('hooks', () => {
}
})
const { context } = await lyla.post(
'http://localhost:8091/api/post-return-headers',
'http://127.0.0.1:8091/api/post-return-headers',
{
headers: {
'x-foo': 'bar'
Expand Down
2 changes: 1 addition & 1 deletion packages/test/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func main() {
StaticRoutes(r)

corsRoutes.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:8091", "http://localhost:3000"},
AllowOrigins: []string{"http://127.0.0.1:8091", "http://127.0.0.1:3000"},
AllowMethods: []string{"GET", "POST"},
ExposeHeaders: []string{"X-Cors", "Set-Cookie"},
AllowCredentials: true,
Expand Down
12 changes: 6 additions & 6 deletions packages/test/tests/cors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ beforeEach(test)

test('cors get', async ({ page }) => {
const { status } = await page.evaluate(async () => {
return await window.lyla.get('http://localhost:8092/api/get-set-cookie', {
return await window.lyla.get('http://127.0.0.1:8092/api/get-set-cookie', {
withCredentials: true
})
})
expect(status).toEqual(200)
const errorType = await page.evaluate(async () => {
try {
await window.lyla.get('http://localhost:8092/api/get-check-cookie')
await window.lyla.get('http://127.0.0.1:8092/api/get-check-cookie')
} catch (e) {
if (window.isLylaError(e)) {
return e.type
Expand All @@ -25,22 +25,22 @@ test('cors get', async ({ page }) => {
})
expect(errorType).toEqual(LYLA_ERROR.HTTP)
await page.evaluate(async () => {
await window.lyla.get('http://localhost:8092/api/get-check-cookie', {
await window.lyla.get('http://127.0.0.1:8092/api/get-check-cookie', {
withCredentials: true
})
})
})

test('cors post', async ({ page }) => {
const { status } = await page.evaluate(async () => {
return await window.lyla.post('http://localhost:8092/api/post-set-cookie', {
return await window.lyla.post('http://127.0.0.1:8092/api/post-set-cookie', {
withCredentials: true
})
})
expect(status).toEqual(200)
const errorType = await page.evaluate(async () => {
try {
await window.lyla.post('http://localhost:8092/api/post-check-cookie')
await window.lyla.post('http://127.0.0.1:8092/api/post-check-cookie')
} catch (e) {
if (window.isLylaError(e)) {
return e.type
Expand All @@ -51,7 +51,7 @@ test('cors post', async ({ page }) => {
})
expect(errorType).toEqual(LYLA_ERROR.HTTP)
await page.evaluate(async () => {
await window.lyla.post('http://localhost:8092/api/post-check-cookie', {
await window.lyla.post('http://127.0.0.1:8092/api/post-check-cookie', {
withCredentials: true
})
})
Expand Down
Loading

0 comments on commit a1caff9

Please sign in to comment.