Skip to content

connect() stalls under Perry-native on Linux (EINPROGRESS, 'connect' never fires); raw net.createConnection works #2

Description

@proggeramlug

Summary

Under a Perry-compiled binary on Linux x86_64, connect() to a local MySQL hangs until connectTimeoutMs and fails with connection timeout after 10000ms. strace shows the TCP socket reaches connect() = EINPROGRESS but the 'connect' event never fires, so the handshake never starts.

The same code works in every other combination:

  • Node.js on the same box → connects.
  • Perry-native on macOS (arm64) → connects (our full service e2e passes natively on macOS).
  • A minimal raw net.createConnection compiled by the same Perry on the same Linux box → connects (even with 'data'/'error' listeners attached and wrapped in top-level await).

So raw net works under Perry-native-Linux, but the driver's connect() path does not — the driver's sock.on('connect', …) callback (connection.ts ~L418, after openSocket at L360) is never invoked.

Repro

net-test.ts (raw stdlib) → CONNECTED natively on Linux:

import * as net from 'net';
const s = net.createConnection(3306, '127.0.0.1');
s.on('connect', () => { console.log('CONNECTED'); s.end(); process.exit(0); });
s.on('data', () => {});                         // even with a data listener
s.on('error', (e) => { console.log('ERR', String(e)); process.exit(1); });
setTimeout(() => { console.log('TIMEOUT'); process.exit(2); }, 5000);

drv-test.ts (this driver) → TIMEOUT natively on Linux (CONNECTED under Node):

import { connect } from '@perryts/mysql';
const c = await connect('mysql://optiq:***@127.0.0.1:3306/optiq');
console.log('CONNECTED', JSON.stringify((await c.query('SELECT 1 AS ok')).rows[0]));
await c.close();

Both compiled with perry compile <file>.ts -o <bin> and run on the same host.

strace (the driver binary)

socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 9
connect(9, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
... no further activity on fd 9 ...
write(2, "Error: connection timeout after 10000ms", 39)

The non-blocking connect() completion (epoll EPOLLOUT) is apparently never observed for the driver's socket, though it is for a bare net.createConnection.

Environment

  • perry 0.5.1125 and 0.5.1129 — both reproduce.
  • @perryts/mysql github HEAD; MySQL 8.4.9 (user is mysql_native_password, require_secure_transport=OFF, bound 127.0.0.1); Ubuntu 26.04 x86_64; clang 21.
  • The mysql CLI and a raw TCP connect to 127.0.0.1:3306 both succeed instantly; MySQL's general log shows no connection attempt from the driver binary (it never completes the handshake).

Impact

Blocks any Perry-native Linux service using the driver. Our optiq-engine (fastify + this driver) compiles and runs end-to-end as a native binary on macOS and under Node on Linux, but the native Linux binary can't reach MySQL because of this. Likely a Perry Linux net interaction rather than a driver-logic bug (raw net works), but filing here since it's observed through the driver — please reclassify to perry if that's the right home.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions