diced / zipline

A ShareX/file upload server that is easy to use, packed with features, and with an easy setup!
https://zipline.diced.sh/
MIT License
1.55k stars 141 forks source link

Bug: v4 - no accessibility #601

Closed Aetherinox closed 2 months ago

Aetherinox commented 2 months ago

What happened?

Just a head's up. I saw that v4 was a possible tag, so I decided to try it for a few just to see what the differences were like.

When I install v4, there's absolutely no connection at all, and no way to access the server. When I access it locally via browser, I just get Unable to connect.


Version

other (provide version in additional info)


What browser(s) are you seeing the problem on?

Firefox, Chromium-based (Chrome, Edge, Brave, Opera, mobile chrome/chromium based, etc)


Zipline Logs

> zipline@4.0.0-dev+1 db:prototype /zipline
> prisma db push && prisma generate

Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "zipline-postgres:5432"

πŸš€  Your database is now in sync with your Prisma schema. Done in 1.18s

Running generate... (Use --skip-generate to skip the generators)
Running generate... - Prisma Client
βœ” Generated Prisma Client (v5.6.0) to ./node_modules/.pnpm/@prisma+client@5.6.0_
prisma@5.6.0/node_modules/@prisma/client in 477ms

Prisma schema loaded from prisma/schema.prisma

βœ” Generated Prisma Client (v5.6.0) to ./node_modules/.pnpm/@prisma+client@5.6.0_prisma@5.6.0/node_modules/@prisma/client in 800ms

Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Update available 5.6.0 -> 5.19.0                       β”‚
β”‚  Run the following to update                            β”‚
β”‚    npm i --save-dev prisma@latest                       β”‚
β”‚    npm i @prisma/client@latest                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

However on restart without the entrypoint, I see:

[2024-09-02T13:56:45 INFO   db] connecting to database postgres://postgres:postgres@ziplinepostgres:5432/postgres?schema=public
[2024-09-02T13:56:45 INFO   server] starting zipline mode="production" version="4.0.0-dev+1"
[2024-09-02T13:56:45 INFO   server] reading environment for configuration
[2024-09-02T13:56:45 ERROR  migrations] failed to apply migrationsError: P3005

The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline

I don't get why it's doing migrations, as I have nothing to migrate. I've completely wiped the db folder and started fresh. Nothing to convert.


The only other errors I noticed was on first run again, I found

2024-09-02 14:06:24.723 UTC [1] LOG:  starting PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

2024-09-02 14:06:24.723 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-09-02 14:06:24.723 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2024-09-02 14:06:24.725 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-09-02 14:06:24.729 UTC [63] LOG:  database system was shut down at 2024-09-02 14:06:24 UTC
2024-09-02 14:06:24.736 UTC [1] LOG:  database system is ready to accept connections
2024-09-02 14:06:27.926 UTC [75] FATAL:  database "zipline" does not exist
2024-09-02 14:06:28.036 UTC [76] FATAL:  database "zipline" does not exist
2024-09-02 14:06:44.271 UTC [83] LOG:  could not receive data from client: Connection reset by peer
2024-09-02 14:07:00.628 UTC [95] LOG:  could not receive data from client: Connection reset by peer
2024-09-02 14:07:09.952 UTC [97] LOG:  could not receive data from client: Connection reset by peer
2024-09-02 14:07:20.783 UTC [100] LOG:  could not receive data from client: Connection reset by peer

And those settings are coming from your v4 branch example.

Browser Logs

No logs.

Only:

Unable to connect

An error occurred during a connection to 172.18.XX.XX.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer’s network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the web.

Additional Info


Docker Compose

v3 runs fine.

services:
    ziplinepostgres:
        container_name: ${PSQL_CONTAINER_NAME:-postgresql}
        image: ${PSQL_IMAGE:-docker.io/library/postgres}:${PSQL_TAG:-15}
        restart: unless-stopped
        environment:
            POSTGRES_DB: ${PSQL_DB_NAME:-postgres}
            POSTGRES_USER: ${PSQL_DB_USER:-postgres}
            POSTGRES_PASSWORD: ${PSQL_DB_PASS:?Database password required.}
        volumes:
            - ./db:/var/lib/postgresql/data
        env_file:
            - ./.env
        healthcheck:
            test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
            start_period: 20s
            interval: 30s
            retries: 5
            timeout: 5s

    zipline:
        container_name: ${ZIPLINE_CONTAINER_NAME:-share}
        image: ${ZIPLINE_IMAGE:-ghcr.io/diced/zipline}:${ZIPLINE_TAG:-latest}
        restart: unless-stopped
        entrypoint: ['pnpm', 'db:prototype']
        environment:
            - DEBUG=true
            - PUID=${PUID}
            - PGID=${PGID}
            - TZ=${SERVER_TIMEZONE}
            - CORE_SECRET=${ZIPLINE_SECRET}
            - DATASOURCE_TYPE=local
            - DATASOURCE_LOCAL_DIRECTORY=./uploads
            - CORE_LOGGER=true
            - DATABASE_URL=postgresql://postgres:postgres@ziplinepostgres:5432/zipline?schema=public
            - CORE_HOST=0.0.0.0
            - CORE_PORT=${ZIPLINE_PORT_MAIN}
        volumes:
            - './uploads:/zipline/uploads'
            - './public:/zipline/public'
        depends_on:
            - 'ziplinepostgres'

Tried about every combination of env vars you can think of. Yet when I migrate back to v3, works perfectly. Tried removing most from v4 thinking it may have changed dramatically.



Yup. The error refuses to go away.

[2024-09-02T14:40:46 INFO   db] connecting to database postgresql://postgres:postgres@172.18.5.2:5432/postgres?schema=public
[2024-09-02T14:40:46 INFO   server] starting zipline mode="production" version="4.0.0-dev+1"
[2024-09-02T14:40:46 INFO   server] reading environment for configuration
[2024-09-02T14:40:46 ERROR  migrations] failed to apply migrationsError: P3005

The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline

I tried both db names, postgres and zipline. default password, and a whole slew of things.

And the Postgres container is just throwing


PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-09-02 14:39:49.424 UTC [1] LOG:  starting PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-09-02 14:39:49.424 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-09-02 14:39:49.424 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2024-09-02 14:39:49.427 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-09-02 14:39:49.431 UTC [29] LOG:  database system was shut down at 2024-09-02 14:39:45 UTC
2024-09-02 14:39:49.437 UTC [1] LOG:  database system is ready to accept connections
2024-09-02 14:39:53.325 UTC [33] LOG:  could not receive data from client: Connection reset by peer
2024-09-02 14:39:57.447 UTC [45] LOG:  could not receive data from client: Connection reset by peer
2024-09-02 14:40:20.621 UTC [61] LOG:  could not receive data from client: Connection reset by peer
2024-09-02 14:40:30.256 UTC [71] LOG:  could not receive data from client: Connection reset by peer
2024-09-02 14:41:15.207 UTC [87] LOG:  could not receive data from client: Connection reset by peer

Fresh install, no existing DB, etc. Got desperate and even assigned a static local ip just for whatever reason. Absolutely no amount of tinkering corrects it.

Opened up port 5432 and connected using DB Beaver from an outside source, and all the tables are there. Connection is fine.

Aetherinox commented 2 months ago

I found the commands on Discord

DO
$$
DECLARE
    r RECORD;
BEGIN
    -- Loop through all table names
    FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public') LOOP
        -- Drop each table
        EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
    END LOOP;
END
$$;

and then I went into the shell for the container, ran the pnpm command, restarted. The console has zero errors now, but the site is still unreachable

[2024-09-02T16:14:34 INFO   db] connecting to database postgresql://postgres:postgres@ziplinepostgres:5432/postgres
[2024-09-02T16:14:34 DEBUG  config::validate] environment validated: {"core":{"port":3000,"hostname":"localhost","secret":"12345678901234567890","databaseUrl":"postgresql://postgres:postgres@ziplinepostgres:5432/postgres","returnHttpsUrls":false,"defaultDomain":null,"tempDirectory":"/tmp/zipline"},"chunks":{"max":99614720,"size":26214400,"enabled":true},"tasks":{"deleteInterval":1800000,"clearInvitesInterval":1800000,"maxViewsInterval":1800000,"thumbnailsInterval":1800000,"metricsInterval":1800000},"files":{"route":"/u","length":6,"defaultFormat":"random","disabledExtensions":[],"maxFileSize":104857600,"defaultExpiration":null,"assumeMimetypes":false,"defaultDateFormat":"YYYY-MM-DD_HH:mm:ss","removeGpsMetadata":false},"urls":{"route":"/go","length":6},"datasource":{"type":"local","local":{"directory":"/zipline/uploads"}},"features":{"imageCompression":true,"robotsTxt":false,"healthcheck":true,"userRegistration":false,"oauthRegistration":false,"deleteOnMaxViews":true,"thumbnails":{"enabled":true,"num_threads":4},"metrics":{"enabled":true,"adminOnly":false,"showUserSpecific":true}},"invites":{"enabled":true,"length":8},"website":{"title":"Zipline","titleLogo":null,"externalLinks":[{"name":"GitHub","url":"https://github.com/diced/zipline"},{"name":"Documentation","url":"https://zipline.diced.tech"}],"loginBackground":null,"defaultAvatar":null,"theme":{"default":"system","dark":"builtin:dark_gray","light":"builtin:light_gray"},"tos":null},"mfa":{"totp":{"enabled":false,"issuer":"Zipline"},"passkeys":true},"oauth":{"bypassLocalLogin":false,"loginOnly":false,"discord":{},"github":{},"google":{},"authentik":{}},"discord":null,"ratelimit":{"enabled":true,"max":10,"window":null,"adminBypass":true,"allowList":[]},"httpWebhook":{"onUpload":null,"onShorten":null},"ssl":{"key":null,"cert":null}}
[2024-09-02T16:14:34 INFO   server] starting zipline mode="production" version="4.0.0-dev+1"
[2024-09-02T16:14:34 INFO   server] reading environment for configuration
[2024-09-02T16:14:34 DEBUG  config::validate] environment validated: {"core":{"port":3000,"hostname":"localhost","secret":"12345678901234567890","databaseUrl":"postgresql://postgres:postgres@ziplinepostgres:5432/postgres","returnHttpsUrls":false,"defaultDomain":null,"tempDirectory":"/tmp/zipline"},"chunks":{"max":99614720,"size":26214400,"enabled":true},"tasks":{"deleteInterval":1800000,"clearInvitesInterval":1800000,"maxViewsInterval":1800000,"thumbnailsInterval":1800000,"metricsInterval":1800000},"files":{"route":"/u","length":6,"defaultFormat":"random","disabledExtensions":[],"maxFileSize":104857600,"defaultExpiration":null,"assumeMimetypes":false,"defaultDateFormat":"YYYY-MM-DD_HH:mm:ss","removeGpsMetadata":false},"urls":{"route":"/go","length":6},"datasource":{"type":"local","local":{"directory":"/zipline/uploads"}},"features":{"imageCompression":true,"robotsTxt":false,"healthcheck":true,"userRegistration":false,"oauthRegistration":false,"deleteOnMaxViews":true,"thumbnails":{"enabled":true,"num_threads":4},"metrics":{"enabled":true,"adminOnly":false,"showUserSpecific":true}},"invites":{"enabled":true,"length":8},"website":{"title":"Zipline","titleLogo":null,"externalLinks":[{"name":"GitHub","url":"https://github.com/diced/zipline"},{"name":"Documentation","url":"https://zipline.diced.tech"}],"loginBackground":null,"defaultAvatar":null,"theme":{"default":"system","dark":"builtin:dark_gray","light":"builtin:light_gray"},"tos":null},"mfa":{"totp":{"enabled":false,"issuer":"Zipline"},"passkeys":true},"oauth":{"bypassLocalLogin":false,"loginOnly":false,"discord":{},"github":{},"google":{},"authentik":{}},"discord":null,"ratelimit":{"enabled":true,"max":10,"window":null,"adminBypass":true,"allowList":[]},"httpWebhook":{"onUpload":null,"onShorten":null},"ssl":{"key":null,"cert":null}}
[2024-09-02T16:14:34 DEBUG  migrations] running migrations...
[2024-09-02T16:14:34 DEBUG  migrations] ensuring database exists...
[2024-09-02T16:14:35 DEBUG  migrations] applying migrations...
[2024-09-02T16:14:35 DEBUG  migrations] no migrations applied
[2024-09-02T16:14:37 INFO   server] server started hostname="localhost" port=3000
[2024-09-02T16:14:37 DEBUG  tasks] starting tasks tasks=9
[2024-09-02T16:14:37 DEBUG  tasks] running first run id="deletefiles"
[2024-09-02T16:14:37 DEBUG  tasks] started interval task id="deletefiles" interval=1800000
[2024-09-02T16:14:37 DEBUG  tasks] running first run id="maxviews"
[2024-09-02T16:14:37 DEBUG  tasks] started interval task id="maxviews" interval=1800000
[2024-09-02T16:14:37 DEBUG  tasks] running first run id="metrics"
[2024-09-02T16:14:37 DEBUG  tasks] started interval task id="metrics" interval=1800000
[2024-09-02T16:14:37 DEBUG  tasks] started worker id="thumbnail-0"
[2024-09-02T16:14:37 DEBUG  tasks] started worker id="thumbnail-1"
[2024-09-02T16:14:37 DEBUG  tasks] started worker id="thumbnail-2"
[2024-09-02T16:14:37 DEBUG  tasks] started worker id="thumbnail-3"
[2024-09-02T16:14:37 DEBUG  tasks] running first run id="thumbnails"
[2024-09-02T16:14:37 DEBUG  tasks] started interval task id="thumbnails" interval=1800000
[2024-09-02T16:14:37 DEBUG  tasks] running first run id="clearinvites"
[2024-09-02T16:14:37 DEBUG  tasks] started interval task id="clearinvites" interval=1800000
[2024-09-02T16:14:41 DEBUG  tasks::thumbnail-0] started thumbnail worker
[2024-09-02T16:14:40 DEBUG  tasks::thumbnail-1] started thumbnail worker
[2024-09-02T16:14:41 DEBUG  tasks::thumbnail-2] started thumbnail worker
[2024-09-02T16:14:40 DEBUG  tasks::thumbnail-3] started thumbnail worker
[2024-09-02T16:14:43 DEBUG  tasks::deletefiles] found 0 expired files files=[]
[2024-09-02T16:14:43 DEBUG  tasks::maxviews] found 0 expired files files=[]
[2024-09-02T16:14:43 DEBUG  tasks::clearinvites] found 0 expired invites files=[]
[2024-09-02T16:14:43 DEBUG  tasks::maxviews] found 0 expired urls dests=[]
[2024-09-02T16:14:43 DEBUG  tasks::clearinvites] found 0 max used invites files=[]
[2024-09-02T16:14:43 DEBUG  tasks::metrics] created metric id="cm0l7baa10000899a48y3pyeh" metric={"files":0,"urls":0,"users":0,"storage":0,"fileViews":0,"urlViews":0,"filesUsers":[],"urlsUsers":[],"types":[]}

HVpZEeuTWi

Tried with and without https, and about a dozen other ways. NO access.