Bug Description
The Slack extension's contract-api.ts re-exports createSlackOutboundPayloadHarness from ./src/outbound-payload-harness.js, which imports vi from vitest and primeChannelOutboundSendMock from openclaw/plugin-sdk/testing. The bundler follows the import chain and includes these test-only dependencies in the production dist.
Runtime Error
When the Slack plugin loads at runtime, dist/extensions/slack/contract-api.js executes:
import { n as vi } from "../../test.p_J6dB8a-Dc5seVFb.js";
import { A as primeChannelOutboundSendMock } from "../../testing-Bq-x5gN1.js";
Since vitest is not available at runtime, vi is undefined, and calling vi.fn() inside createSlackOutboundPayloadHarness throws:
TypeError: Cannot read properties of undefined (reading 't')
(t is the minified name of fn)
Root Cause
extensions/slack/contract-api.ts line 6:
export { createSlackOutboundPayloadHarness } from "./src/outbound-payload-harness.js";
extensions/slack/src/outbound-payload-harness.ts imports:
import { primeChannelOutboundSendMock } from "openclaw/plugin-sdk/testing";
import { vi } from "vitest";
This is a test-only function exported through a production barrel, causing the bundler to pull vitest into the production build.
Affected Version
v2026.4.7 confirmed. Likely also affects v2026.4.8+ since the source (contract-api.ts) still contains the same export on main.
Impact
- Severity: Low — the error is non-fatal and does not block Slack plugin functionality
- Scope: Slack plugin loading logs an error on startup
Suggested Fix
Remove the createSlackOutboundPayloadHarness export from extensions/slack/contract-api.ts. Test files that need it can import directly from ./src/outbound-payload-harness.js:
test/helpers/channels/outbound-payload-contract.ts
extensions/slack/src/outbound-payload.test.ts
Reproduction
- Install openclaw v2026.4.7
- Enable the Slack plugin
- Observe the
TypeError: Cannot read properties of undefined (reading 't') error during startup
Bug Description
The Slack extension's
contract-api.tsre-exportscreateSlackOutboundPayloadHarnessfrom./src/outbound-payload-harness.js, which importsvifromvitestandprimeChannelOutboundSendMockfromopenclaw/plugin-sdk/testing. The bundler follows the import chain and includes these test-only dependencies in the production dist.Runtime Error
When the Slack plugin loads at runtime,
dist/extensions/slack/contract-api.jsexecutes:Since
vitestis not available at runtime,viisundefined, and callingvi.fn()insidecreateSlackOutboundPayloadHarnessthrows:(
tis the minified name offn)Root Cause
extensions/slack/contract-api.tsline 6:extensions/slack/src/outbound-payload-harness.tsimports:This is a test-only function exported through a production barrel, causing the bundler to pull vitest into the production build.
Affected Version
v2026.4.7 confirmed. Likely also affects v2026.4.8+ since the source (
contract-api.ts) still contains the same export onmain.Impact
Suggested Fix
Remove the
createSlackOutboundPayloadHarnessexport fromextensions/slack/contract-api.ts. Test files that need it can import directly from./src/outbound-payload-harness.js:test/helpers/channels/outbound-payload-contract.tsextensions/slack/src/outbound-payload.test.tsReproduction
TypeError: Cannot read properties of undefined (reading 't')error during startup