Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ export default class Client extends API {
// assumes HttpConnection
clientMeta += `,hc=${nodeVersion}`
}

// detect alternative runtimes
if (process.versions.bun != null) clientMeta += `,bn=${process.versions.bun}`
if (process.versions.deno != null) clientMeta += `,dn=${process.versions.deno}`

options.headers['x-elastic-client-meta'] = clientMeta
}

Expand Down
36 changes: 36 additions & 0 deletions test/unit/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,42 @@ test('Meta header indicates when HttpConnection is used', async t => {
await client.transport.request({ method: 'GET', path: '/' })
})

test('Meta header indicates when Bun is used', async t => {
t.plan(1)

function handler(req: http.IncomingMessage, res: http.ServerResponse) {
t.equal(req.headers['x-elastic-client-meta'], `es=${clientVersion},js=${nodeVersion},t=${transportVersion},un=${nodeVersion},bn=1.2.3`)
res.end('ok')
}

const [{ port }, server] = await buildServer(handler)
t.after(() => server.stop())

process.versions.bun = "1.2.3"
const client = new Client({ node: `http://localhost:${port}` })
delete process.versions.bun

await client.transport.request({ method: 'GET', path: '/' })
})

test('Meta header indicates when Deno is used', async t => {
t.plan(1)

function handler(req: http.IncomingMessage, res: http.ServerResponse) {
t.equal(req.headers['x-elastic-client-meta'], `es=${clientVersion},js=${nodeVersion},t=${transportVersion},un=${nodeVersion},dn=1.2.3`)
res.end('ok')
}

const [{ port }, server] = await buildServer(handler)
t.after(() => server.stop())

process.versions.deno = "1.2.3"
const client = new Client({ node: `http://localhost:${port}` })
delete process.versions.deno

await client.transport.request({ method: 'GET', path: '/' })
})

test('caFingerprint', t => {
const client = new Client({
node: 'https://localhost:9200',
Expand Down
Loading