Skip to content

Calling connect() after keepalive() #44

@gnois

Description

@gnois

This used to work in 1.6 but no longer in 1.7 or 1.8, with error
.../pgmoon/init.lua:194: attempt to index field 'sock' (a nil value)

File app/db.lua

local pg = require('pgmoon')
return pg.new({...})

File app/handler.lua

local db = require('app.db')
function ware1(db)
	db:connect()
	-- do work
	db:keepalive()
end

function ware2(db)
	db:connect()
	-- do work
	db:keepalive()
end

function handler(db)
	ware1(db)
	-- do some work
	ware2(db)
	-- do more work
end

I found that the self.sock handle is set to nil after keepalive().
Can we call connect() after keepalive() if they are within the same request?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions