Compare commits

..

1 Commits

Author SHA1 Message Date
Matti Nannt 6955d7c99f fix: clean up setTimeout schedules in contact effects
Two useEffect hooks scheduled `setTimeout` callbacks without returning
a cleanup. If the effect re-ran (or the component unmounted) before the
timeout fired, the callback would still execute against stale state /
unmounted refs. Capture the timeout id and return `() => clearTimeout(id)`.

Flagged by react-doctor as react-doctor/effect-needs-cleanup
(State & Effects, error).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 14:41:43 +02:00
3 changed files with 9 additions and 7 deletions
+5 -5
View File
@@ -18,9 +18,9 @@ FROM node:24-alpine3.23 AS base
FROM base AS installer
# Enable corepack and prepare pnpm
RUN npm install --ignore-scripts -g corepack@0.35.0
RUN npm install --ignore-scripts -g corepack@latest
RUN corepack enable
RUN corepack prepare pnpm@10.32.1 --activate
RUN corepack prepare pnpm@10.28.2 --activate
# Install necessary build tools and compilers
RUN apk update && apk add --no-cache cmake g++ gcc jq make openssl-dev python3
@@ -56,7 +56,7 @@ COPY . .
RUN touch apps/web/.env
# Install the dependencies
RUN pnpm install --ignore-scripts --frozen-lockfile
RUN pnpm install --ignore-scripts
# Build the database package first
RUN pnpm build --filter=@formbricks/database
@@ -82,7 +82,7 @@ FROM base AS runner
# Upgrade Alpine system packages to pick up security patches, update npm to latest, then create user
# Note: npm's bundled tar has a known vulnerability but npm is only used during build, not at runtime
RUN apk update && apk upgrade --no-cache \
&& npm install --ignore-scripts -g npm@11.15.0 \
&& npm install --ignore-scripts -g npm@latest \
&& addgroup -S nextjs \
&& adduser -S -u 1001 -G nextjs nextjs
@@ -155,7 +155,7 @@ COPY --from=installer /app/node_modules/otlp-logger ./node_modules/otlp-logger
RUN chmod -R 755 ./node_modules/otlp-logger
# Install prisma CLI globally for database migrations and fix permissions for nextjs user
RUN npm install --ignore-scripts -g prisma@6.19.3 \
RUN npm install --ignore-scripts -g prisma@6 \
&& chown -R nextjs:nextjs /usr/local/lib/node_modules/prisma
# Create a startup script to handle the conditional logic
@@ -133,7 +133,7 @@ export const EditContactAttributesModal = ({
const errorFieldId = `attribute-key-${firstErrorIndex}`;
const errorElement = document.getElementById(errorFieldId);
if (errorElement) {
setTimeout(() => {
const timeoutId = setTimeout(() => {
errorElement.scrollIntoView({ behavior: "smooth", block: "center" });
// Try to focus the input inside the combobox if it exists
const inputElement = errorElement.querySelector("input") as HTMLInputElement;
@@ -143,6 +143,7 @@ export const EditContactAttributesModal = ({
errorElement.focus();
}
}, 100);
return () => clearTimeout(timeoutId);
}
}
}
@@ -337,9 +337,10 @@ export const UploadContactsCSVButton = ({
useEffect(() => {
if (error && errorContainerRef.current) {
// Small delay to ensure DOM has updated and the alert is visible
setTimeout(() => {
const timeoutId = setTimeout(() => {
errorContainerRef.current?.scrollIntoView({ behavior: "smooth", block: "center" });
}, 100);
return () => clearTimeout(timeoutId);
}
}, [error]);