Skip to content

fix(next): inline pairing-token env via literal process.env - #16

Merged
Seungwoo321 merged 3 commits into
mainfrom
develop
Jun 27, 2026
Merged

fix(next): inline pairing-token env via literal process.env#16
Seungwoo321 merged 3 commits into
mainfrom
develop

Conversation

@Seungwoo321

Copy link
Copy Markdown
Owner

Summary

  • Next.js App Router 클라이언트 번들에서 환경변수가 undefined로 평가되어 위젯이 마운트되지 않던 문제 수정
  • 번들러의 정적 치환이 동작하도록 process.env.<KEY> 리터럴 멤버 접근으로 변경

Root Cause

  • 기존 globalThis.process.env[key] 동적 조회 방식은 번들러가 컴파일 타임에 정적 치환할 수 없음
  • Next.js App Router 클라이언트 번들은 런타임 process 객체가 없어 (typeof process === 'undefined') 환경변수 조회가 undefined 반환
  • 위젯이 활성화 플래그/베이스 URL/페어링 토큰을 읽지 못해 마운트 실패

Fix

  • readEnv() 함수를 리터럴 process.env.<KEY> 표현식으로 재작성
  • webpack DefinePlugin / Turbopack의 env-config 인라이닝이 빌드 타임에 dev 값을 치환하도록 수정
  • AGENT_DEVTOOLS_NEXT_ENABLED, AGENT_DEVTOOLS_NEXT_BASE_URL, AGENT_DEVTOOLS_NEXT_PAIRING_TOKEN 세 환경변수 모두 리터럴 접근으로 통일
  • 프로덕션 dev-only 가드는 기존 로직 유지

Changes

  • packages/next/src/bootstrap.ts: readEnv() 함수의 환경변수 읽기 로직을 동적 조회에서 리터럴 멤버 접근으로 변경
  • packages/next/src/bootstrap.test.ts: createAgentCommandsFetcher 스파이 추가 (테스트 커버리지 강화)
  • .changeset/next-bootstrap-literal-env.md: 패치 버전 변경 로그 추가

Test Plan

  • Next.js 16 + Turbopack 환경에서 App Router 클라이언트 번들 검증
  • 브라우저 콘솔에서 typeof process === 'undefined' 확인 후 위젯 마운트 성공 확인
  • 기존 단위 테스트 통과 확인
  • dev 서버 실행 후 위젯 UI 정상 렌더링 확인
  • 환경변수 설정 후 페어링 토큰 정상 전달 확인

github-actions Bot and others added 3 commits June 18, 2026 01:51
…outer

readEnv read the enabled flag / base URL / pairing token through a dynamic
globalThis.process.env[key] lookup, which bundlers cannot statically replace.
The Next App Router client bundle has no runtime process object, so the lookup
resolved to undefined and the widget never mounted (verified on Next 16 +
Turbopack). Switch to literal process.env.<KEY> access so Next env-config
inlining substitutes the dev values at build time. Also adds the missing
createAgentCommandsFetcher export to the bootstrap test mock (3 pre-existing
red tests now green; 27/27 pass).
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-devtools-docs Ready Ready Preview, Comment Jun 27, 2026 8:34am

Request Review

@Seungwoo321
Seungwoo321 merged commit e26e5c6 into main Jun 27, 2026
1 of 2 checks passed
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

Successfully merging this pull request may close these issues.

1 participant